From f4092abdf94af6a99aff944d6264bc1284e8bdd4 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 10 Oct 2011 17:43:39 +0200 Subject: Imported nx-X11-3.1.0-1.tar.gz Summary: Imported nx-X11-3.1.0-1.tar.gz Keywords: Imported nx-X11-3.1.0-1.tar.gz into Git repository --- nx-X11/programs/Xserver/GL/Imakefile | 66 + nx-X11/programs/Xserver/GL/apple/Imakefile | 49 + nx-X11/programs/Xserver/GL/apple/aglGlx.c | 1355 +++++ nx-X11/programs/Xserver/GL/apple/indirect.c | 1380 +++++ nx-X11/programs/Xserver/GL/dri/Imakefile | 35 + .../programs/Xserver/GL/dri/Imakefile.NX.reference | 35 + .../Xserver/GL/dri/Imakefile.XF86.reference | 34 + nx-X11/programs/Xserver/GL/dri/dri-def.cpp | 50 + nx-X11/programs/Xserver/GL/dri/dri.c | 2109 +++++++ nx-X11/programs/Xserver/GL/dri/dri.h | 345 ++ nx-X11/programs/Xserver/GL/dri/drimodule.c | 127 + nx-X11/programs/Xserver/GL/dri/dristruct.h | 105 + nx-X11/programs/Xserver/GL/dri/sarea.h | 94 + nx-X11/programs/Xserver/GL/dri/xf86dri.c | 649 ++ nx-X11/programs/Xserver/GL/glx/Imakefile | 118 + nx-X11/programs/Xserver/GL/glx/g_disptab.c | 839 +++ nx-X11/programs/Xserver/GL/glx/g_disptab.h | 652 ++ nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.c | 4447 ++++++++++++++ nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.h | 159 + nx-X11/programs/Xserver/GL/glx/g_render.c | 2282 +++++++ nx-X11/programs/Xserver/GL/glx/g_renderswap.c | 3387 +++++++++++ nx-X11/programs/Xserver/GL/glx/g_single.c | 1787 ++++++ nx-X11/programs/Xserver/GL/glx/g_singleswap.c | 2208 +++++++ nx-X11/programs/Xserver/GL/glx/global.c | 76 + nx-X11/programs/Xserver/GL/glx/glx-def.cpp | 662 +++ nx-X11/programs/Xserver/GL/glx/glxbuf.c | 296 + nx-X11/programs/Xserver/GL/glx/glxbuf.h | 57 + nx-X11/programs/Xserver/GL/glx/glxcmds.c | 2156 +++++++ nx-X11/programs/Xserver/GL/glx/glxcmdsswap.c | 871 +++ nx-X11/programs/Xserver/GL/glx/glxcontext.h | 164 + nx-X11/programs/Xserver/GL/glx/glxdrawable.h | 112 + nx-X11/programs/Xserver/GL/glx/glxerror.h | 58 + nx-X11/programs/Xserver/GL/glx/glxext.c | 505 ++ nx-X11/programs/Xserver/GL/glx/glxext.h | 131 + nx-X11/programs/Xserver/GL/glx/glxfb.c | 183 + nx-X11/programs/Xserver/GL/glx/glxfb.h | 52 + nx-X11/programs/Xserver/GL/glx/glximports.c | 184 + nx-X11/programs/Xserver/GL/glx/glximports.h | 66 + nx-X11/programs/Xserver/GL/glx/glxmem.c | 151 + nx-X11/programs/Xserver/GL/glx/glxmem.h | 48 + nx-X11/programs/Xserver/GL/glx/glxpix.c | 132 + nx-X11/programs/Xserver/GL/glx/glxpix.h | 48 + nx-X11/programs/Xserver/GL/glx/glxscreens.c | 378 ++ nx-X11/programs/Xserver/GL/glx/glxscreens.h | 103 + nx-X11/programs/Xserver/GL/glx/glxserver.h | 287 + nx-X11/programs/Xserver/GL/glx/glxutil.c | 507 ++ nx-X11/programs/Xserver/GL/glx/glxutil.h | 84 + nx-X11/programs/Xserver/GL/glx/impsize.h | 56 + nx-X11/programs/Xserver/GL/glx/module/Imakefile | 4 + nx-X11/programs/Xserver/GL/glx/render2.c | 271 + nx-X11/programs/Xserver/GL/glx/render2swap.c | 393 ++ nx-X11/programs/Xserver/GL/glx/renderpix.c | 312 + nx-X11/programs/Xserver/GL/glx/renderpixswap.c | 555 ++ nx-X11/programs/Xserver/GL/glx/rensize.c | 987 ++++ nx-X11/programs/Xserver/GL/glx/rensizetab.c | 2448 ++++++++ nx-X11/programs/Xserver/GL/glx/single2.c | 411 ++ nx-X11/programs/Xserver/GL/glx/single2swap.c | 303 + nx-X11/programs/Xserver/GL/glx/singlepix.c | 462 ++ nx-X11/programs/Xserver/GL/glx/singlepixswap.c | 518 ++ nx-X11/programs/Xserver/GL/glx/singlesize.c | 1222 ++++ nx-X11/programs/Xserver/GL/glx/singlesize.h | 87 + nx-X11/programs/Xserver/GL/glx/unpack.h | 240 + nx-X11/programs/Xserver/GL/glx/xfont.c | 195 + nx-X11/programs/Xserver/GL/glxmodule.c | 1270 ++++ nx-X11/programs/Xserver/GL/include/GL/glx_ansic.h | 115 + nx-X11/programs/Xserver/GL/include/GL/xf86glx.h | 43 + .../programs/Xserver/GL/mesa/GLcore/GLcore-def.cpp | 1462 +++++ .../programs/Xserver/GL/mesa/GLcore/GLcoremodule.c | 64 + nx-X11/programs/Xserver/GL/mesa/GLcore/Imakefile | 77 + .../Xserver/GL/mesa/GLcore/module/Imakefile | 53 + nx-X11/programs/Xserver/GL/mesa/Imakefile | 47 + nx-X11/programs/Xserver/GL/mesa/X/Imakefile | 93 + nx-X11/programs/Xserver/GL/mesa/X/module/Imakefile | 6 + nx-X11/programs/Xserver/GL/mesa/X/xf86glx.c | 914 +++ nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.c | 151 + nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.h | 106 + nx-X11/programs/Xserver/GL/mesa/X/xf86glxint.h | 102 + .../programs/Xserver/GL/mesa/array_cache/Imakefile | 56 + .../Xserver/GL/mesa/array_cache/module/Imakefile | 6 + nx-X11/programs/Xserver/GL/mesa/main/Imakefile | 61 + .../programs/Xserver/GL/mesa/main/module/Imakefile | 6 + nx-X11/programs/Xserver/GL/mesa/math/Imakefile | 55 + .../programs/Xserver/GL/mesa/math/module/Imakefile | 6 + nx-X11/programs/Xserver/GL/mesa/shader/Imakefile | 59 + .../Xserver/GL/mesa/shader/grammar/Imakefile | 54 + .../Xserver/GL/mesa/shader/slang/Imakefile | 59 + .../Xserver/GL/mesa/shader/slang/library/Imakefile | 46 + nx-X11/programs/Xserver/GL/mesa/swrast/Imakefile | 63 + .../Xserver/GL/mesa/swrast/module/Imakefile | 6 + .../Xserver/GL/mesa/swrast_setup/Imakefile | 55 + .../Xserver/GL/mesa/swrast_setup/module/Imakefile | 6 + nx-X11/programs/Xserver/GL/mesa/tnl/Imakefile | 66 + .../programs/Xserver/GL/mesa/tnl/module/Imakefile | 6 + nx-X11/programs/Xserver/GL/opengl/Imakefile | 140 + nx-X11/programs/Xserver/GL/windows/ChangeLog | 64 + nx-X11/programs/Xserver/GL/windows/Imakefile | 36 + nx-X11/programs/Xserver/GL/windows/glwindows.h | 64 + nx-X11/programs/Xserver/GL/windows/glwrap.c | 583 ++ nx-X11/programs/Xserver/GL/windows/indirect.c | 1605 +++++ nx-X11/programs/Xserver/Imakefile | 1579 +++++ nx-X11/programs/Xserver/Imakefile.NX.original | 1579 +++++ nx-X11/programs/Xserver/Imakefile.X.original | 1242 ++++ nx-X11/programs/Xserver/XFree86.def | 5 + nx-X11/programs/Xserver/XTrap/Imakefile | 27 + nx-X11/programs/Xserver/XTrap/module/Imakefile | 26 + nx-X11/programs/Xserver/XTrap/xf86XTrapModule.c | 51 + nx-X11/programs/Xserver/XTrap/xtrapddmi.c | 188 + nx-X11/programs/Xserver/XTrap/xtrapdi.c | 2157 +++++++ nx-X11/programs/Xserver/XTrap/xtrapdiswp.c | 1010 ++++ nx-X11/programs/Xserver/XTrap/xtrapditbl.c | 242 + nx-X11/programs/Xserver/Xext/EVI.c | 202 + nx-X11/programs/Xserver/Xext/EVIstruct.h | 60 + nx-X11/programs/Xserver/Xext/Imakefile | 226 + nx-X11/programs/Xserver/Xext/Imakefile.NX.original | 226 + nx-X11/programs/Xserver/Xext/Imakefile.X.original | 200 + nx-X11/programs/Xserver/Xext/SecurityPolicy | 88 + nx-X11/programs/Xserver/Xext/appgroup.c | 829 +++ nx-X11/programs/Xserver/Xext/appgroup.h | 10 + nx-X11/programs/Xserver/Xext/bigreq.c | 107 + nx-X11/programs/Xserver/Xext/cup.c | 364 ++ nx-X11/programs/Xserver/Xext/dgaproc.h | 144 + nx-X11/programs/Xserver/Xext/dmx.c | 1133 ++++ nx-X11/programs/Xserver/Xext/dpms.c | 450 ++ nx-X11/programs/Xserver/Xext/dpmsproc.h | 16 + nx-X11/programs/Xserver/Xext/dpmsstubs.c | 54 + nx-X11/programs/Xserver/Xext/extmod/Imakefile | 127 + nx-X11/programs/Xserver/Xext/extmod/modinit.c | 264 + nx-X11/programs/Xserver/Xext/extmod/modinit.h | 149 + nx-X11/programs/Xserver/Xext/fontcache.c | 333 ++ nx-X11/programs/Xserver/Xext/mbuf.c | 1787 ++++++ nx-X11/programs/Xserver/Xext/mbufbf.c | 1030 ++++ nx-X11/programs/Xserver/Xext/mbufpx.c | 651 ++ nx-X11/programs/Xserver/Xext/mitmisc.c | 176 + nx-X11/programs/Xserver/Xext/panoramiX.c | 1308 ++++ nx-X11/programs/Xserver/Xext/panoramiX.h | 115 + nx-X11/programs/Xserver/Xext/panoramiXSwap.c | 144 + nx-X11/programs/Xserver/Xext/panoramiXh.h | 78 + nx-X11/programs/Xserver/Xext/panoramiXprocs.c | 2372 ++++++++ nx-X11/programs/Xserver/Xext/panoramiXsrv.h | 50 + nx-X11/programs/Xserver/Xext/sampleEVI.c | 106 + nx-X11/programs/Xserver/Xext/saver.c | 1415 +++++ nx-X11/programs/Xserver/Xext/security.c | 2241 +++++++ .../programs/Xserver/Xext/security.c.NX.original | 2241 +++++++ nx-X11/programs/Xserver/Xext/security.c.X.original | 2004 +++++++ nx-X11/programs/Xserver/Xext/shape.c | 1335 +++++ nx-X11/programs/Xserver/Xext/shm.c | 1267 ++++ nx-X11/programs/Xserver/Xext/sleepuntil.c | 239 + nx-X11/programs/Xserver/Xext/sleepuntil.h | 47 + nx-X11/programs/Xserver/Xext/sync.c | 2513 ++++++++ nx-X11/programs/Xserver/Xext/vidmodeproc.h | 78 + nx-X11/programs/Xserver/Xext/xcmisc.c | 253 + nx-X11/programs/Xserver/Xext/xevie.c | 719 +++ nx-X11/programs/Xserver/Xext/xf86bigfont.c | 790 +++ nx-X11/programs/Xserver/Xext/xf86dga.c | 307 + nx-X11/programs/Xserver/Xext/xf86dga2.c | 775 +++ nx-X11/programs/Xserver/Xext/xf86dgaext.h | 12 + nx-X11/programs/Xserver/Xext/xf86misc.c | 854 +++ nx-X11/programs/Xserver/Xext/xf86miscproc.h | 70 + nx-X11/programs/Xserver/Xext/xf86vmode.c | 2206 +++++++ nx-X11/programs/Xserver/Xext/xprint.c | 2760 +++++++++ nx-X11/programs/Xserver/Xext/xres.c | 339 ++ nx-X11/programs/Xserver/Xext/xtest.c | 608 ++ nx-X11/programs/Xserver/Xext/xtest1.frags | 90 + nx-X11/programs/Xserver/Xext/xtest1dd.c | 1617 +++++ nx-X11/programs/Xserver/Xext/xtest1dd.h | 127 + nx-X11/programs/Xserver/Xext/xtest1di.c | 954 +++ nx-X11/programs/Xserver/Xext/xvdisp.c | 2217 +++++++ nx-X11/programs/Xserver/Xext/xvdisp.h | 3 + nx-X11/programs/Xserver/Xext/xvdix.h | 291 + nx-X11/programs/Xserver/Xext/xvmain.c | 1203 ++++ nx-X11/programs/Xserver/Xext/xvmc.c | 796 +++ nx-X11/programs/Xserver/Xext/xvmcext.h | 116 + nx-X11/programs/Xserver/Xext/xvmod.c | 24 + nx-X11/programs/Xserver/Xext/xvmodproc.h | 14 + nx-X11/programs/Xserver/Xi/Imakefile | 94 + nx-X11/programs/Xserver/Xi/allowev.c | 145 + nx-X11/programs/Xserver/Xi/allowev.h | 44 + nx-X11/programs/Xserver/Xi/chgdctl.c | 219 + nx-X11/programs/Xserver/Xi/chgdctl.h | 51 + nx-X11/programs/Xserver/Xi/chgfctl.c | 663 +++ nx-X11/programs/Xserver/Xi/chgfctl.h | 98 + nx-X11/programs/Xserver/Xi/chgkbd.c | 216 + nx-X11/programs/Xserver/Xi/chgkbd.h | 52 + nx-X11/programs/Xserver/Xi/chgkmap.c | 136 + nx-X11/programs/Xserver/Xi/chgkmap.h | 44 + nx-X11/programs/Xserver/Xi/chgprop.c | 174 + nx-X11/programs/Xserver/Xi/chgprop.h | 44 + nx-X11/programs/Xserver/Xi/chgptr.c | 262 + nx-X11/programs/Xserver/Xi/chgptr.h | 73 + nx-X11/programs/Xserver/Xi/closedev.c | 191 + nx-X11/programs/Xserver/Xi/closedev.h | 58 + nx-X11/programs/Xserver/Xi/devbell.c | 173 + nx-X11/programs/Xserver/Xi/devbell.h | 44 + nx-X11/programs/Xserver/Xi/exevents.c | 1366 +++++ nx-X11/programs/Xserver/Xi/exglobals.h | 80 + nx-X11/programs/Xserver/Xi/extinit.c | 1016 ++++ nx-X11/programs/Xserver/Xi/getbmap.c | 154 + nx-X11/programs/Xserver/Xi/getbmap.h | 51 + nx-X11/programs/Xserver/Xi/getdctl.c | 230 + nx-X11/programs/Xserver/Xi/getdctl.h | 59 + nx-X11/programs/Xserver/Xi/getfctl.c | 422 ++ nx-X11/programs/Xserver/Xi/getfctl.h | 93 + nx-X11/programs/Xserver/Xi/getfocus.c | 157 + nx-X11/programs/Xserver/Xi/getfocus.h | 51 + nx-X11/programs/Xserver/Xi/getkmap.c | 178 + nx-X11/programs/Xserver/Xi/getkmap.h | 51 + nx-X11/programs/Xserver/Xi/getmmap.c | 158 + nx-X11/programs/Xserver/Xi/getmmap.h | 51 + nx-X11/programs/Xserver/Xi/getprop.c | 215 + nx-X11/programs/Xserver/Xi/getprop.h | 60 + nx-X11/programs/Xserver/Xi/getselev.c | 196 + nx-X11/programs/Xserver/Xi/getselev.h | 51 + nx-X11/programs/Xserver/Xi/getvers.c | 157 + nx-X11/programs/Xserver/Xi/getvers.h | 51 + nx-X11/programs/Xserver/Xi/grabdev.c | 232 + nx-X11/programs/Xserver/Xi/grabdev.h | 61 + nx-X11/programs/Xserver/Xi/grabdevb.c | 170 + nx-X11/programs/Xserver/Xi/grabdevb.h | 44 + nx-X11/programs/Xserver/Xi/grabdevk.c | 174 + nx-X11/programs/Xserver/Xi/grabdevk.h | 44 + nx-X11/programs/Xserver/Xi/gtmotion.c | 213 + nx-X11/programs/Xserver/Xi/gtmotion.h | 51 + nx-X11/programs/Xserver/Xi/listdev.c | 407 ++ nx-X11/programs/Xserver/Xi/listdev.h | 103 + nx-X11/programs/Xserver/Xi/opendev.c | 205 + nx-X11/programs/Xserver/Xi/opendev.h | 51 + nx-X11/programs/Xserver/Xi/queryst.c | 215 + nx-X11/programs/Xserver/Xi/queryst.h | 51 + nx-X11/programs/Xserver/Xi/selectev.c | 159 + nx-X11/programs/Xserver/Xi/selectev.h | 44 + nx-X11/programs/Xserver/Xi/sendexev.c | 181 + nx-X11/programs/Xserver/Xi/sendexev.h | 44 + nx-X11/programs/Xserver/Xi/setbmap.c | 170 + nx-X11/programs/Xserver/Xi/setbmap.h | 51 + nx-X11/programs/Xserver/Xi/setdval.c | 174 + nx-X11/programs/Xserver/Xi/setdval.h | 51 + nx-X11/programs/Xserver/Xi/setfocus.c | 126 + nx-X11/programs/Xserver/Xi/setfocus.h | 44 + nx-X11/programs/Xserver/Xi/setmmap.c | 164 + nx-X11/programs/Xserver/Xi/setmmap.h | 51 + nx-X11/programs/Xserver/Xi/setmode.c | 158 + nx-X11/programs/Xserver/Xi/setmode.h | 51 + nx-X11/programs/Xserver/Xi/stubs.c | 317 + nx-X11/programs/Xserver/Xi/ungrdev.c | 123 + nx-X11/programs/Xserver/Xi/ungrdev.h | 44 + nx-X11/programs/Xserver/Xi/ungrdevb.c | 178 + nx-X11/programs/Xserver/Xi/ungrdevb.h | 44 + nx-X11/programs/Xserver/Xi/ungrdevk.c | 184 + nx-X11/programs/Xserver/Xi/ungrdevk.h | 44 + nx-X11/programs/Xserver/Xnest.def | 4 + nx-X11/programs/Xserver/Xorg.def | 5 + nx-X11/programs/Xserver/XpConfig/C/Imakefile | 8 + nx-X11/programs/Xserver/XpConfig/C/print/Imakefile | 23 + nx-X11/programs/Xserver/XpConfig/C/print/Xprinters | 49 + .../Xserver/XpConfig/C/print/attributes/Imakefile | 8 + .../Xserver/XpConfig/C/print/attributes/document | 49 + .../Xserver/XpConfig/C/print/attributes/job | 25 + .../Xserver/XpConfig/C/print/attributes/printer | 96 + .../Xserver/XpConfig/C/print/ddx-config/Imakefile | 8 + .../XpConfig/C/print/ddx-config/raster/Imakefile | 6 + .../Xserver/XpConfig/C/print/ddx-config/raster/pcl | 39 + .../XpConfig/C/print/ddx-config/raster/postscript | 0 .../C/print/models/CANONBJ10E-GS/Imakefile | 15 + .../C/print/models/CANONBJ10E-GS/model-config | 23 + .../C/print/models/CANONC3200-PS/Imakefile | 15 + .../C/print/models/CANONC3200-PS/fonts/Imakefile | 45 + .../C/print/models/CANONC3200-PS/model-config | 40 + .../XpConfig/C/print/models/GSdefault/Imakefile | 14 + .../XpConfig/C/print/models/GSdefault/model-config | 137 + .../XpConfig/C/print/models/HPDJ1600C/Imakefile | 14 + .../C/print/models/HPDJ1600C/fonts/9nb00051.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPDJ1600C/fonts/9nb00052.pmf | Bin 0 -> 5736 bytes .../C/print/models/HPDJ1600C/fonts/9nb00053.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPDJ1600C/fonts/9nb00054.pmf | Bin 0 -> 5744 bytes .../C/print/models/HPDJ1600C/fonts/9nb00055.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPDJ1600C/fonts/9nb00056.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPDJ1600C/fonts/9nb00057.pmf | Bin 0 -> 5632 bytes .../C/print/models/HPDJ1600C/fonts/9nb00058.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPDJ1600C/fonts/9nb00059.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPDJ1600C/fonts/9nb00060.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPDJ1600C/fonts/9nb00061.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPDJ1600C/fonts/9nb00062.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPDJ1600C/fonts/9nb00063.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPDJ1600C/fonts/9nb00064.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPDJ1600C/fonts/9nb00065.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPDJ1600C/fonts/9nb00066.pmf | Bin 0 -> 5732 bytes .../C/print/models/HPDJ1600C/fonts/9nb00067.pmf | Bin 0 -> 5736 bytes .../C/print/models/HPDJ1600C/fonts/9nb00068.pmf | Bin 0 -> 5732 bytes .../C/print/models/HPDJ1600C/fonts/9nb00069.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPDJ1600C/fonts/9nb00070.pmf | Bin 0 -> 5744 bytes .../C/print/models/HPDJ1600C/fonts/9nb00071.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPDJ1600C/fonts/9nb00072.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPDJ1600C/fonts/9nb00073.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPDJ1600C/fonts/9nb00074.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPDJ1600C/fonts/9nb00075.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPDJ1600C/fonts/9nb00076.pmf | Bin 0 -> 5716 bytes .../C/print/models/HPDJ1600C/fonts/9nb00077.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPDJ1600C/fonts/9nb00079.pmf | Bin 0 -> 5656 bytes .../C/print/models/HPDJ1600C/fonts/9nb00080.pmf | Bin 0 -> 5664 bytes .../C/print/models/HPDJ1600C/fonts/9nb00081.pmf | Bin 0 -> 5672 bytes .../C/print/models/HPDJ1600C/fonts/9nb00082.pmf | Bin 0 -> 5660 bytes .../C/print/models/HPDJ1600C/fonts/9nb00083.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPDJ1600C/fonts/9nb00084.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPDJ1600C/fonts/9nb00085.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPDJ1600C/fonts/9nb00086.pmf | Bin 0 -> 5716 bytes .../C/print/models/HPDJ1600C/fonts/9nb00087.pmf | Bin 0 -> 5752 bytes .../C/print/models/HPDJ1600C/fonts/9nb00088.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPDJ1600C/fonts/9nb00089.pmf | Bin 0 -> 5744 bytes .../C/print/models/HPDJ1600C/fonts/9nb00090.pmf | Bin 0 -> 5736 bytes .../C/print/models/HPDJ1600C/fonts/9nb00091.pmf | Bin 0 -> 5744 bytes .../C/print/models/HPDJ1600C/fonts/9nb00092.pmf | Bin 0 -> 5736 bytes .../C/print/models/HPDJ1600C/fonts/9nb00093.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPDJ1600C/fonts/9nb00094.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPDJ1600C/fonts/Imakefile | 57 + .../XpConfig/C/print/models/HPDJ1600C/fonts/README | 197 + .../C/print/models/HPDJ1600C/fonts/fonts.alias | 0 .../C/print/models/HPDJ1600C/fonts/fonts.dir | 45 + .../C/print/models/HPDJ1600C/fonts/lpr0ye1a.pmf | Bin 0 -> 4296 bytes .../XpConfig/C/print/models/HPDJ1600C/model-config | 40 + .../XpConfig/C/print/models/HPLJ4050-PS/Imakefile | 15 + .../C/print/models/HPLJ4050-PS/fonts/Imakefile | 45 + .../C/print/models/HPLJ4050-PS/model-config | 36 + .../XpConfig/C/print/models/HPLJ4family/Imakefile | 14 + .../C/print/models/HPLJ4family/fonts/9nb00051.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPLJ4family/fonts/9nb00052.pmf | Bin 0 -> 5736 bytes .../C/print/models/HPLJ4family/fonts/9nb00053.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPLJ4family/fonts/9nb00054.pmf | Bin 0 -> 5744 bytes .../C/print/models/HPLJ4family/fonts/9nb00055.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPLJ4family/fonts/9nb00056.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPLJ4family/fonts/9nb00057.pmf | Bin 0 -> 5632 bytes .../C/print/models/HPLJ4family/fonts/9nb00058.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPLJ4family/fonts/9nb00059.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPLJ4family/fonts/9nb00060.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPLJ4family/fonts/9nb00061.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPLJ4family/fonts/9nb00062.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPLJ4family/fonts/9nb00063.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPLJ4family/fonts/9nb00064.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPLJ4family/fonts/9nb00065.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPLJ4family/fonts/9nb00066.pmf | Bin 0 -> 5732 bytes .../C/print/models/HPLJ4family/fonts/9nb00067.pmf | Bin 0 -> 5736 bytes .../C/print/models/HPLJ4family/fonts/9nb00068.pmf | Bin 0 -> 5732 bytes .../C/print/models/HPLJ4family/fonts/9nb00069.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPLJ4family/fonts/9nb00070.pmf | Bin 0 -> 5744 bytes .../C/print/models/HPLJ4family/fonts/9nb00071.pmf | Bin 0 -> 5740 bytes .../C/print/models/HPLJ4family/fonts/9nb00072.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPLJ4family/fonts/9nb00073.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPLJ4family/fonts/9nb00074.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPLJ4family/fonts/9nb00075.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPLJ4family/fonts/9nb00076.pmf | Bin 0 -> 5716 bytes .../C/print/models/HPLJ4family/fonts/9nb00077.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPLJ4family/fonts/9nb00079.pmf | Bin 0 -> 5656 bytes .../C/print/models/HPLJ4family/fonts/9nb00080.pmf | Bin 0 -> 5664 bytes .../C/print/models/HPLJ4family/fonts/9nb00081.pmf | Bin 0 -> 5672 bytes .../C/print/models/HPLJ4family/fonts/9nb00082.pmf | Bin 0 -> 5660 bytes .../C/print/models/HPLJ4family/fonts/9nb00083.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPLJ4family/fonts/9nb00084.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPLJ4family/fonts/9nb00085.pmf | Bin 0 -> 5724 bytes .../C/print/models/HPLJ4family/fonts/9nb00086.pmf | Bin 0 -> 5716 bytes .../C/print/models/HPLJ4family/fonts/9nb00087.pmf | Bin 0 -> 5752 bytes .../C/print/models/HPLJ4family/fonts/9nb00088.pmf | Bin 0 -> 5720 bytes .../C/print/models/HPLJ4family/fonts/9nb00089.pmf | Bin 0 -> 5744 bytes .../C/print/models/HPLJ4family/fonts/9nb00090.pmf | Bin 0 -> 5736 bytes .../C/print/models/HPLJ4family/fonts/9nb00091.pmf | Bin 0 -> 5744 bytes .../C/print/models/HPLJ4family/fonts/9nb00092.pmf | Bin 0 -> 5736 bytes .../C/print/models/HPLJ4family/fonts/9nb00093.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPLJ4family/fonts/9nb00094.pmf | Bin 0 -> 5728 bytes .../C/print/models/HPLJ4family/fonts/Imakefile | 56 + .../C/print/models/HPLJ4family/fonts/README | 203 + .../C/print/models/HPLJ4family/fonts/fonts.alias | 0 .../C/print/models/HPLJ4family/fonts/fonts.dir | 45 + .../C/print/models/HPLJ4family/fonts/lpr0ye1a.pmf | Bin 0 -> 4296 bytes .../C/print/models/HPLJ4family/model-config | 39 + .../Xserver/XpConfig/C/print/models/Imakefile | 45 + .../C/print/models/PS2PDFspooldir-GS/Imakefile | 35 + .../C/print/models/PS2PDFspooldir-GS/model-config | 72 + .../models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh | 130 + .../XpConfig/C/print/models/PSdefault/Imakefile | 14 + .../models/PSdefault/fonts/AvantGarde-Book.pmf | Bin 0 -> 6716 bytes .../PSdefault/fonts/AvantGarde-BookOblique.pmf | Bin 0 -> 6728 bytes .../models/PSdefault/fonts/AvantGarde-Demi.pmf | Bin 0 -> 6712 bytes .../PSdefault/fonts/AvantGarde-DemiOblique.pmf | Bin 0 -> 6724 bytes .../print/models/PSdefault/fonts/Courier-Bold.pmf | Bin 0 -> 6612 bytes .../models/PSdefault/fonts/Courier-BoldOblique.pmf | Bin 0 -> 6636 bytes .../models/PSdefault/fonts/Courier-Oblique.pmf | Bin 0 -> 6608 bytes .../C/print/models/PSdefault/fonts/Courier.pmf | Bin 0 -> 6592 bytes .../models/PSdefault/fonts/Helvetica-Bold.pmf | Bin 0 -> 6680 bytes .../PSdefault/fonts/Helvetica-BoldOblique.pmf | Bin 0 -> 6692 bytes .../models/PSdefault/fonts/Helvetica-Oblique.pmf | Bin 0 -> 6688 bytes .../C/print/models/PSdefault/fonts/Helvetica.pmf | Bin 0 -> 6672 bytes .../C/print/models/PSdefault/fonts/Imakefile | 41 + .../models/PSdefault/fonts/LubalinGraph-Book.pmf | Bin 0 -> 6628 bytes .../PSdefault/fonts/LubalinGraph-BookOblique.pmf | Bin 0 -> 6640 bytes .../models/PSdefault/fonts/LubalinGraph-Demi.pmf | Bin 0 -> 6624 bytes .../PSdefault/fonts/LubalinGraph-DemiOblique.pmf | Bin 0 -> 6636 bytes .../PSdefault/fonts/NewCenturySchlbk-Bold.pmf | Bin 0 -> 6644 bytes .../fonts/NewCenturySchlbk-BoldItalic.pmf | Bin 0 -> 6656 bytes .../PSdefault/fonts/NewCenturySchlbk-Italic.pmf | Bin 0 -> 6652 bytes .../PSdefault/fonts/NewCenturySchlbk-Roman.pmf | Bin 0 -> 6648 bytes .../print/models/PSdefault/fonts/Souvenir-Demi.pmf | Bin 0 -> 6680 bytes .../models/PSdefault/fonts/Souvenir-DemiItalic.pmf | Bin 0 -> 6692 bytes .../models/PSdefault/fonts/Souvenir-Light.pmf | Bin 0 -> 6684 bytes .../PSdefault/fonts/Souvenir-LightItalic.pmf | Bin 0 -> 6696 bytes .../C/print/models/PSdefault/fonts/Symbol.pmf | Bin 0 -> 6556 bytes .../C/print/models/PSdefault/fonts/Times-Bold.pmf | Bin 0 -> 6660 bytes .../models/PSdefault/fonts/Times-BoldItalic.pmf | Bin 0 -> 6672 bytes .../print/models/PSdefault/fonts/Times-Italic.pmf | Bin 0 -> 6668 bytes .../C/print/models/PSdefault/fonts/Times-Roman.pmf | Bin 0 -> 6664 bytes .../print/models/PSdefault/fonts/ZapfDingbats.pmf | Bin 0 -> 6676 bytes .../XpConfig/C/print/models/PSdefault/model-config | 136 + .../XpConfig/C/print/models/PSspooldir/Imakefile | 34 + .../C/print/models/PSspooldir/model-config | 71 + .../C/print/models/PSspooldir/spooltodir.sh | 127 + .../XpConfig/C/print/models/SPSPARC2/Imakefile | 15 + .../C/print/models/SPSPARC2/fonts/Imakefile | 28 + .../XpConfig/C/print/models/SPSPARC2/model-config | 18 + nx-X11/programs/Xserver/XpConfig/Imakefile | 761 +++ nx-X11/programs/Xserver/XpConfig/README | 318 + nx-X11/programs/Xserver/XpConfig/en_US/Imakefile | 8 + .../Xserver/XpConfig/en_US/print/Imakefile | 26 + .../XpConfig/en_US/print/attributes/Imakefile | 18 + .../XpConfig/en_US/print/attributes/document | 13 + nx-X11/programs/Xserver/Xprint/AttrValid.c | 702 +++ nx-X11/programs/Xserver/Xprint/AttrValid.h | 216 + nx-X11/programs/Xserver/Xprint/DiPrint.h | 81 + nx-X11/programs/Xserver/Xprint/Imakefile | 135 + nx-X11/programs/Xserver/Xprint/Init.c | 1934 ++++++ nx-X11/programs/Xserver/Xprint/Oid.c | 3184 ++++++++++ nx-X11/programs/Xserver/Xprint/Oid.h | 294 + nx-X11/programs/Xserver/Xprint/OidDefs.h | 171 + nx-X11/programs/Xserver/Xprint/OidStrs.h | 173 + nx-X11/programs/Xserver/Xprint/Util.c | 372 ++ nx-X11/programs/Xserver/Xprint/ValTree.c | 193 + nx-X11/programs/Xserver/Xprint/Xprt.html | 115 + nx-X11/programs/Xserver/Xprint/Xprt.man | 196 + nx-X11/programs/Xserver/Xprint/Xprt.sgml | 371 ++ nx-X11/programs/Xserver/Xprint/attributes.c | 1740 ++++++ nx-X11/programs/Xserver/Xprint/attributes.h | 131 + nx-X11/programs/Xserver/Xprint/ddxInit.c | 397 ++ nx-X11/programs/Xserver/Xprint/etc/Imakefile | 24 + .../Xserver/Xprint/etc/Xsession.d/Imakefile | 24 + .../Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh | 30 + .../programs/Xserver/Xprint/etc/init.d/Imakefile | 97 + .../programs/Xserver/Xprint/etc/init.d/xprint.cpp | 1277 ++++ .../Xserver/Xprint/etc/profile.d/Imakefile | 14 + .../Xserver/Xprint/etc/profile.d/xprint.csh | 16 + .../Xserver/Xprint/etc/profile.d/xprint.sh | 16 + nx-X11/programs/Xserver/Xprint/mediaSizes.c | 783 +++ nx-X11/programs/Xserver/Xprint/pcl-mono/Imakefile | 6 + nx-X11/programs/Xserver/Xprint/pcl/Imakefile | 76 + nx-X11/programs/Xserver/Xprint/pcl/Pcl.h | 625 ++ nx-X11/programs/Xserver/Xprint/pcl/PclArc.c | 270 + nx-X11/programs/Xserver/Xprint/pcl/PclArea.c | 486 ++ nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c | 207 + nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c | 87 + nx-X11/programs/Xserver/Xprint/pcl/PclColor.c | 851 +++ nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c | 115 + nx-X11/programs/Xserver/Xprint/pcl/PclDef.h | 68 + nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c | 74 + nx-X11/programs/Xserver/Xprint/pcl/PclGC.c | 1046 ++++ nx-X11/programs/Xserver/Xprint/pcl/PclInit.c | 631 ++ nx-X11/programs/Xserver/Xprint/pcl/PclLine.c | 316 + nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c | 306 + nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c | 159 + nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c | 85 + nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c | 353 ++ nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c | 711 +++ nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c | 429 ++ nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h | 116 + nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c | 139 + nx-X11/programs/Xserver/Xprint/pcl/PclText.c | 936 +++ nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c | 452 ++ nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h | 213 + nx-X11/programs/Xserver/Xprint/pdf/README | 1 + nx-X11/programs/Xserver/Xprint/ps/Imakefile | 89 + nx-X11/programs/Xserver/Xprint/ps/Ps.h | 590 ++ nx-X11/programs/Xserver/Xprint/ps/PsArc.c | 182 + nx-X11/programs/Xserver/Xprint/ps/PsArea.c | 393 ++ nx-X11/programs/Xserver/Xprint/ps/PsAttVal.c | 290 + nx-X11/programs/Xserver/Xprint/ps/PsAttr.c | 117 + nx-X11/programs/Xserver/Xprint/ps/PsCache.c | 328 + nx-X11/programs/Xserver/Xprint/ps/PsColor.c | 258 + nx-X11/programs/Xserver/Xprint/ps/PsDef.h | 97 + nx-X11/programs/Xserver/Xprint/ps/PsFTFonts.c | 85 + nx-X11/programs/Xserver/Xprint/ps/PsFonts.c | 876 +++ nx-X11/programs/Xserver/Xprint/ps/PsGC.c | 419 ++ nx-X11/programs/Xserver/Xprint/ps/PsImageUtil.c | 329 ++ nx-X11/programs/Xserver/Xprint/ps/PsInit.c | 667 +++ nx-X11/programs/Xserver/Xprint/ps/PsLine.c | 192 + nx-X11/programs/Xserver/Xprint/ps/PsMisc.c | 324 + nx-X11/programs/Xserver/Xprint/ps/PsPixel.c | 157 + nx-X11/programs/Xserver/Xprint/ps/PsPixmap.c | 617 ++ nx-X11/programs/Xserver/Xprint/ps/PsPolygon.c | 262 + nx-X11/programs/Xserver/Xprint/ps/PsPrint.c | 462 ++ nx-X11/programs/Xserver/Xprint/ps/PsSpans.c | 166 + nx-X11/programs/Xserver/Xprint/ps/PsText.c | 586 ++ nx-X11/programs/Xserver/Xprint/ps/PsWindow.c | 462 ++ nx-X11/programs/Xserver/Xprint/ps/psout.c | 1792 ++++++ nx-X11/programs/Xserver/Xprint/ps/psout.h | 335 ++ nx-X11/programs/Xserver/Xprint/ps/psout_ft.c | 335 ++ .../programs/Xserver/Xprint/ps/psout_ftpstype1.c | 185 + .../programs/Xserver/Xprint/ps/psout_ftpstype3.c | 468 ++ nx-X11/programs/Xserver/Xprint/ps/ttf2pt1wrap.c | 14 + nx-X11/programs/Xserver/Xprint/raster/Imakefile | 28 + nx-X11/programs/Xserver/Xprint/raster/Raster.c | 1580 +++++ nx-X11/programs/Xserver/Xprint/raster/Raster.h | 118 + .../programs/Xserver/Xprint/raster/RasterAttVal.c | 269 + nx-X11/programs/Xserver/Xprint/spooler.c | 204 + nx-X11/programs/Xserver/Xprint/spooler.h | 76 + nx-X11/programs/Xserver/Xprint/svg/README | 1 + nx-X11/programs/Xserver/Xprint/windows/README | 1 + nx-X11/programs/Xserver/Xserver.man | 790 +++ nx-X11/programs/Xserver/Xvfb.def | 4 + nx-X11/programs/Xserver/afb/Imakefile | 67 + nx-X11/programs/Xserver/afb/README | 10 + nx-X11/programs/Xserver/afb/Xdaniver.doc | 218 + nx-X11/programs/Xserver/afb/afb.h | 1132 ++++ nx-X11/programs/Xserver/afb/afbbitblt.c | 477 ++ nx-X11/programs/Xserver/afb/afbblt.c | 563 ++ nx-X11/programs/Xserver/afb/afbbres.c | 325 + nx-X11/programs/Xserver/afb/afbbresd.c | 216 + nx-X11/programs/Xserver/afb/afbbstore.c | 156 + nx-X11/programs/Xserver/afb/afbclip.c | 248 + nx-X11/programs/Xserver/afb/afbcmap.c | 125 + nx-X11/programs/Xserver/afb/afbfillarc.c | 359 ++ nx-X11/programs/Xserver/afb/afbfillrct.c | 294 + nx-X11/programs/Xserver/afb/afbfillsp.c | 1131 ++++ nx-X11/programs/Xserver/afb/afbfont.c | 79 + nx-X11/programs/Xserver/afb/afbgc.c | 711 +++ nx-X11/programs/Xserver/afb/afbgetsp.c | 167 + nx-X11/programs/Xserver/afb/afbhrzvert.c | 211 + nx-X11/programs/Xserver/afb/afbimage.c | 301 + nx-X11/programs/Xserver/afb/afbimggblt.c | 474 ++ nx-X11/programs/Xserver/afb/afbline.c | 706 +++ nx-X11/programs/Xserver/afb/afbmisc.c | 96 + nx-X11/programs/Xserver/afb/afbmodule.c | 63 + nx-X11/programs/Xserver/afb/afbpixmap.c | 300 + nx-X11/programs/Xserver/afb/afbply1rct.c | 300 + nx-X11/programs/Xserver/afb/afbplygblt.c | 465 ++ nx-X11/programs/Xserver/afb/afbpntarea.c | 657 +++ nx-X11/programs/Xserver/afb/afbpntwin.c | 128 + nx-X11/programs/Xserver/afb/afbpolypnt.c | 148 + nx-X11/programs/Xserver/afb/afbpushpxl.c | 259 + nx-X11/programs/Xserver/afb/afbscrinit.c | 248 + nx-X11/programs/Xserver/afb/afbsetsp.c | 269 + nx-X11/programs/Xserver/afb/afbtegblt.c | 588 ++ nx-X11/programs/Xserver/afb/afbtile.c | 859 +++ nx-X11/programs/Xserver/afb/afbwindow.c | 318 + nx-X11/programs/Xserver/afb/afbzerarc.c | 210 + nx-X11/programs/Xserver/cfb/Imakefile | 6 + nx-X11/programs/Xserver/cfb/Imakefile.inc | 303 + nx-X11/programs/Xserver/cfb/cfb.h | 1327 +++++ nx-X11/programs/Xserver/cfb/cfb16.h | 94 + nx-X11/programs/Xserver/cfb/cfb24.h | 98 + nx-X11/programs/Xserver/cfb/cfb32.h | 94 + nx-X11/programs/Xserver/cfb/cfb8bit.c | 471 ++ nx-X11/programs/Xserver/cfb/cfb8bit.h | 1572 +++++ nx-X11/programs/Xserver/cfb/cfb8line.c | 1504 +++++ nx-X11/programs/Xserver/cfb/cfballpriv.c | 94 + nx-X11/programs/Xserver/cfb/cfbbitblt.c | 1454 +++++ nx-X11/programs/Xserver/cfb/cfbblt.c | 933 +++ nx-X11/programs/Xserver/cfb/cfbbres.c | 342 ++ nx-X11/programs/Xserver/cfb/cfbbresd.c | 406 ++ nx-X11/programs/Xserver/cfb/cfbbstore.c | 145 + nx-X11/programs/Xserver/cfb/cfbcmap.c | 121 + nx-X11/programs/Xserver/cfb/cfbcppl.c | 490 ++ nx-X11/programs/Xserver/cfb/cfbfillarc.c | 374 ++ nx-X11/programs/Xserver/cfb/cfbfillrct.c | 307 + nx-X11/programs/Xserver/cfb/cfbfillsp.c | 1006 ++++ nx-X11/programs/Xserver/cfb/cfbgc.c | 811 +++ nx-X11/programs/Xserver/cfb/cfbgetsp.c | 215 + nx-X11/programs/Xserver/cfb/cfbglblt8.c | 479 ++ nx-X11/programs/Xserver/cfb/cfbhrzvert.c | 556 ++ nx-X11/programs/Xserver/cfb/cfbigblt8.c | 108 + nx-X11/programs/Xserver/cfb/cfbimage.c | 206 + nx-X11/programs/Xserver/cfb/cfbline.c | 757 +++ nx-X11/programs/Xserver/cfb/cfbmap.h | 344 ++ nx-X11/programs/Xserver/cfb/cfbmodule.c | 65 + nx-X11/programs/Xserver/cfb/cfbmskbits.c | 1402 +++++ nx-X11/programs/Xserver/cfb/cfbmskbits.h | 897 +++ nx-X11/programs/Xserver/cfb/cfbpixmap.c | 376 ++ nx-X11/programs/Xserver/cfb/cfbply1rct.c | 363 ++ nx-X11/programs/Xserver/cfb/cfbpntwin.c | 771 +++ nx-X11/programs/Xserver/cfb/cfbpolypnt.c | 204 + nx-X11/programs/Xserver/cfb/cfbpush8.c | 186 + nx-X11/programs/Xserver/cfb/cfbrctstp8.c | 595 ++ nx-X11/programs/Xserver/cfb/cfbrrop.c | 229 + nx-X11/programs/Xserver/cfb/cfbrrop.h | 343 ++ nx-X11/programs/Xserver/cfb/cfbscrinit.c | 232 + nx-X11/programs/Xserver/cfb/cfbsetsp.c | 318 + nx-X11/programs/Xserver/cfb/cfbsolid.c | 1367 +++++ nx-X11/programs/Xserver/cfb/cfbtab.h | 16 + nx-X11/programs/Xserver/cfb/cfbteblt8.c | 591 ++ nx-X11/programs/Xserver/cfb/cfbtegblt.c | 220 + nx-X11/programs/Xserver/cfb/cfbtile32.c | 519 ++ nx-X11/programs/Xserver/cfb/cfbtileodd.c | 1247 ++++ nx-X11/programs/Xserver/cfb/cfbunmap.h | 165 + nx-X11/programs/Xserver/cfb/cfbwindow.c | 337 ++ nx-X11/programs/Xserver/cfb/cfbzerarc.c | 322 + nx-X11/programs/Xserver/cfb/module/Imakefile | 11 + nx-X11/programs/Xserver/cfb/stip68kgnu.h | 123 + nx-X11/programs/Xserver/cfb/stipmips.s | 281 + nx-X11/programs/Xserver/cfb/stipple68k.s | 231 + nx-X11/programs/Xserver/cfb/stipsparc.s | 290 + nx-X11/programs/Xserver/cfb/stipsprc32.s | 291 + nx-X11/programs/Xserver/cfb16/Imakefile | 10 + nx-X11/programs/Xserver/cfb16/cfbmodule.c | 65 + nx-X11/programs/Xserver/cfb16/module/Imakefile | 12 + nx-X11/programs/Xserver/cfb24/Imakefile | 6 + nx-X11/programs/Xserver/cfb24/cfbmodule.c | 65 + nx-X11/programs/Xserver/cfb24/cfbrrop24.h | 54 + nx-X11/programs/Xserver/cfb24/module/Imakefile | 12 + nx-X11/programs/Xserver/cfb32/Imakefile | 10 + nx-X11/programs/Xserver/cfb32/cfbmodule.c | 65 + nx-X11/programs/Xserver/cfb32/module/Imakefile | 12 + nx-X11/programs/Xserver/composite/Imakefile | 18 + nx-X11/programs/Xserver/composite/compalloc.c | 553 ++ nx-X11/programs/Xserver/composite/compext.c | 409 ++ nx-X11/programs/Xserver/composite/compinit.c | 390 ++ nx-X11/programs/Xserver/composite/compint.h | 260 + nx-X11/programs/Xserver/composite/compwindow.c | 755 +++ nx-X11/programs/Xserver/damageext/Imakefile | 17 + nx-X11/programs/Xserver/damageext/damageext.c | 481 ++ nx-X11/programs/Xserver/damageext/damageext.h | 35 + nx-X11/programs/Xserver/damageext/damageextint.h | 88 + nx-X11/programs/Xserver/dbe/Imakefile | 36 + nx-X11/programs/Xserver/dbe/dbe.c | 1999 +++++++ nx-X11/programs/Xserver/dbe/dbemodule.c | 48 + nx-X11/programs/Xserver/dbe/dbestruct.h | 237 + nx-X11/programs/Xserver/dbe/midbe.c | 855 +++ nx-X11/programs/Xserver/dbe/midbe.h | 51 + nx-X11/programs/Xserver/dbe/midbestr.h | 100 + nx-X11/programs/Xserver/dbe/module/Imakefile | 34 + nx-X11/programs/Xserver/dix/BuiltInAtoms | 329 ++ nx-X11/programs/Xserver/dix/CHANGES | 17 + nx-X11/programs/Xserver/dix/Imakefile | 101 + nx-X11/programs/Xserver/dix/atom.c | 213 + nx-X11/programs/Xserver/dix/buildatoms | 43 + nx-X11/programs/Xserver/dix/colormap.c | 2793 +++++++++ nx-X11/programs/Xserver/dix/cursor.c | 459 ++ nx-X11/programs/Xserver/dix/devices.c | 1665 ++++++ nx-X11/programs/Xserver/dix/dispatch.c | 4035 +++++++++++++ nx-X11/programs/Xserver/dix/dispatch.h | 147 + nx-X11/programs/Xserver/dix/dixfonts.c | 2208 +++++++ nx-X11/programs/Xserver/dix/dixfonts.c.NX.original | 2208 +++++++ nx-X11/programs/Xserver/dix/dixfonts.c.X.original | 2143 +++++++ nx-X11/programs/Xserver/dix/dixutils.c | 962 +++ nx-X11/programs/Xserver/dix/events.c | 4670 +++++++++++++++ nx-X11/programs/Xserver/dix/extension.c | 474 ++ nx-X11/programs/Xserver/dix/ffs.c | 37 + nx-X11/programs/Xserver/dix/gc.c | 1288 ++++ nx-X11/programs/Xserver/dix/globals.c | 163 + nx-X11/programs/Xserver/dix/glyphcurs.c | 194 + nx-X11/programs/Xserver/dix/grabs.c | 438 ++ nx-X11/programs/Xserver/dix/initatoms.c | 84 + nx-X11/programs/Xserver/dix/main.c | 800 +++ nx-X11/programs/Xserver/dix/pixmap.c | 152 + nx-X11/programs/Xserver/dix/pixmap.c.NX.original | 152 + nx-X11/programs/Xserver/dix/pixmap.c.X.original | 145 + nx-X11/programs/Xserver/dix/privates.c | 401 ++ nx-X11/programs/Xserver/dix/property.c | 729 +++ nx-X11/programs/Xserver/dix/resource.c | 954 +++ nx-X11/programs/Xserver/dix/swaprep.c | 1309 ++++ nx-X11/programs/Xserver/dix/swapreq.c | 1104 ++++ nx-X11/programs/Xserver/dix/tables.c | 529 ++ nx-X11/programs/Xserver/dix/window.c | 3853 ++++++++++++ nx-X11/programs/Xserver/dix/xpstubs.c | 77 + nx-X11/programs/Xserver/fb/Imakefile | 194 + nx-X11/programs/Xserver/fb/Imakefile.NX.original | 194 + nx-X11/programs/Xserver/fb/Imakefile.X.original | 188 + nx-X11/programs/Xserver/fb/fb.h | 2054 +++++++ nx-X11/programs/Xserver/fb/fb24_32.c | 627 ++ nx-X11/programs/Xserver/fb/fb24_32.h | 53 + nx-X11/programs/Xserver/fb/fballpriv.c | 93 + nx-X11/programs/Xserver/fb/fbarc.c | 122 + nx-X11/programs/Xserver/fb/fbbits.c | 179 + nx-X11/programs/Xserver/fb/fbbits.h | 964 +++ nx-X11/programs/Xserver/fb/fbblt.c | 933 +++ nx-X11/programs/Xserver/fb/fbbltone.c | 880 +++ nx-X11/programs/Xserver/fb/fbbstore.c | 66 + nx-X11/programs/Xserver/fb/fbcmap.c | 672 +++ nx-X11/programs/Xserver/fb/fbcompose.c | 3627 ++++++++++++ nx-X11/programs/Xserver/fb/fbcopy.c | 663 +++ nx-X11/programs/Xserver/fb/fbedge.c | 314 + nx-X11/programs/Xserver/fb/fbedgeimp.h | 143 + nx-X11/programs/Xserver/fb/fbfill.c | 222 + nx-X11/programs/Xserver/fb/fbfillrect.c | 115 + nx-X11/programs/Xserver/fb/fbfillsp.c | 103 + nx-X11/programs/Xserver/fb/fbgc.c | 317 + nx-X11/programs/Xserver/fb/fbgetsp.c | 88 + nx-X11/programs/Xserver/fb/fbglyph.c | 479 ++ nx-X11/programs/Xserver/fb/fbimage.c | 368 ++ nx-X11/programs/Xserver/fb/fbline.c | 177 + nx-X11/programs/Xserver/fb/fbmmx.c | 2276 +++++++ nx-X11/programs/Xserver/fb/fbmmx.h | 220 + nx-X11/programs/Xserver/fb/fbmodule.c | 53 + nx-X11/programs/Xserver/fb/fboverlay.c | 457 ++ nx-X11/programs/Xserver/fb/fboverlay.h | 129 + nx-X11/programs/Xserver/fb/fbpict.c | 1456 +++++ nx-X11/programs/Xserver/fb/fbpict.h | 612 ++ nx-X11/programs/Xserver/fb/fbpixmap.c | 389 ++ nx-X11/programs/Xserver/fb/fbpoint.c | 164 + nx-X11/programs/Xserver/fb/fbpseudocolor.c | 2335 ++++++++ nx-X11/programs/Xserver/fb/fbpseudocolor.h | 20 + nx-X11/programs/Xserver/fb/fbpush.c | 247 + nx-X11/programs/Xserver/fb/fbrop.h | 139 + nx-X11/programs/Xserver/fb/fbscreen.c | 301 + nx-X11/programs/Xserver/fb/fbseg.c | 727 +++ nx-X11/programs/Xserver/fb/fbsetsp.c | 104 + nx-X11/programs/Xserver/fb/fbsolid.c | 215 + nx-X11/programs/Xserver/fb/fbstipple.c | 316 + nx-X11/programs/Xserver/fb/fbtile.c | 204 + nx-X11/programs/Xserver/fb/fbtrap.c | 239 + nx-X11/programs/Xserver/fb/fbutil.c | 365 ++ nx-X11/programs/Xserver/fb/fbwindow.c | 352 ++ nx-X11/programs/Xserver/fb/module/Imakefile | 6 + nx-X11/programs/Xserver/hw/Imakefile | 26 + nx-X11/programs/Xserver/hw/darwin/Imakefile | 92 + nx-X11/programs/Xserver/hw/darwin/XDarwin.man | 205 + .../hw/darwin/bundle/Dutch.lproj/Credits.rtf | 168 + .../Xserver/hw/darwin/bundle/Dutch.lproj/Imakefile | 36 + .../darwin/bundle/Dutch.lproj/Localizable.strings | Bin 0 -> 1426 bytes .../bundle/Dutch.lproj/MainMenu.nib/classes.nib | 72 + .../bundle/Dutch.lproj/MainMenu.nib/objects.nib | Bin 0 -> 22024 bytes .../darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp | 103 + .../hw/darwin/bundle/English.lproj/Credits.rtf | 168 + .../hw/darwin/bundle/English.lproj/Imakefile | 34 + .../bundle/English.lproj/InfoPlist.strings.cpp | 5 + .../bundle/English.lproj/Localizable.strings | 23 + .../bundle/English.lproj/MainMenu.nib/classes.nib | 72 + .../bundle/English.lproj/MainMenu.nib/objects.nib | Bin 0 -> 20829 bytes .../bundle/English.lproj/XDarwinHelp.html.cpp | 96 + .../hw/darwin/bundle/French.lproj/Credits.rtf | 166 + .../hw/darwin/bundle/French.lproj/Imakefile | 36 + .../darwin/bundle/French.lproj/Localizable.strings | Bin 0 -> 1492 bytes .../bundle/French.lproj/MainMenu.nib/classes.nib | 72 + .../bundle/French.lproj/MainMenu.nib/objects.nib | Bin 0 -> 21114 bytes .../bundle/French.lproj/XDarwinHelp.html.cpp | 101 + .../hw/darwin/bundle/German.lproj/Credits.rtf | 168 + .../hw/darwin/bundle/German.lproj/Imakefile | 36 + .../darwin/bundle/German.lproj/Localizable.strings | Bin 0 -> 1458 bytes .../bundle/German.lproj/MainMenu.nib/classes.nib | 72 + .../bundle/German.lproj/MainMenu.nib/objects.nib | Bin 0 -> 21182 bytes .../bundle/German.lproj/XDarwinHelp.html.cpp | 96 + nx-X11/programs/Xserver/hw/darwin/bundle/Imakefile | 15 + .../hw/darwin/bundle/Japanese.lproj/Credits.rtf | 193 + .../hw/darwin/bundle/Japanese.lproj/Imakefile | 36 + .../bundle/Japanese.lproj/Localizable.strings | Bin 0 -> 1152 bytes .../bundle/Japanese.lproj/MainMenu.nib/classes.nib | 72 + .../bundle/Japanese.lproj/MainMenu.nib/objects.nib | Bin 0 -> 21854 bytes .../bundle/Japanese.lproj/XDarwinHelp.html.cpp | 141 + .../hw/darwin/bundle/Portuguese.lproj/Credits.rtf | 171 + .../hw/darwin/bundle/Portuguese.lproj/Imakefile | 36 + .../bundle/Portuguese.lproj/Localizable.strings | Bin 0 -> 1504 bytes .../Portuguese.lproj/MainMenu.nib/classes.nib | 72 + .../Portuguese.lproj/MainMenu.nib/objects.nib | Bin 0 -> 21112 bytes .../bundle/Portuguese.lproj/XDarwinHelp.html.cpp | 211 + .../hw/darwin/bundle/Spanish.lproj/Credits.rtf | 168 + .../hw/darwin/bundle/Spanish.lproj/Imakefile | 36 + .../bundle/Spanish.lproj/Localizable.strings | Bin 0 -> 1480 bytes .../bundle/Spanish.lproj/MainMenu.nib/classes.nib | 72 + .../bundle/Spanish.lproj/MainMenu.nib/objects.nib | Bin 0 -> 20952 bytes .../bundle/Spanish.lproj/XDarwinHelp.html.cpp | 111 + .../hw/darwin/bundle/Swedish.lproj/Credits.rtf | 168 + .../hw/darwin/bundle/Swedish.lproj/Imakefile | 36 + .../bundle/Swedish.lproj/Localizable.strings | Bin 0 -> 1464 bytes .../bundle/Swedish.lproj/MainMenu.nib/classes.nib | 72 + .../bundle/Swedish.lproj/MainMenu.nib/objects.nib | Bin 0 -> 20858 bytes .../bundle/Swedish.lproj/XDarwinHelp.html.cpp | 103 + .../programs/Xserver/hw/darwin/bundle/XDarwin.icns | Bin 0 -> 69465 bytes .../Xserver/hw/darwin/bundle/ko.lproj/Credits.rtf | 168 + .../Xserver/hw/darwin/bundle/ko.lproj/Imakefile | 36 + .../hw/darwin/bundle/ko.lproj/Localizable.strings | Bin 0 -> 1332 bytes .../bundle/ko.lproj/MainMenu.nib/classes.nib | 72 + .../bundle/ko.lproj/MainMenu.nib/objects.nib | Bin 0 -> 21433 bytes .../hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp | 96 + .../Xserver/hw/darwin/bundle/startXClients.cpp | 24 + nx-X11/programs/Xserver/hw/darwin/darwin.c | 1108 ++++ nx-X11/programs/Xserver/hw/darwin/darwin.h | 153 + nx-X11/programs/Xserver/hw/darwin/darwinClut8.h | 532 ++ nx-X11/programs/Xserver/hw/darwin/darwinEvents.c | 481 ++ nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.c | 1027 ++++ nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.h | 52 + nx-X11/programs/Xserver/hw/darwin/darwinXinput.c | 310 + nx-X11/programs/Xserver/hw/darwin/iokit/Imakefile | 25 + nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.c | 772 +++ nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.h | 57 + .../Xserver/hw/darwin/iokit/xfIOKitCursor.c | 735 +++ .../Xserver/hw/darwin/iokit/xfIOKitStartup.c | 126 + nx-X11/programs/Xserver/hw/darwin/quartz/Imakefile | 113 + .../Xserver/hw/darwin/quartz/Preferences.h | 138 + .../Xserver/hw/darwin/quartz/Preferences.m | 597 ++ .../Xserver/hw/darwin/quartz/XApplication.h | 47 + .../Xserver/hw/darwin/quartz/XApplication.m | 47 + .../darwin/quartz/XDarwin.pbproj/project.pbxproj | 2519 ++++++++ .../Xserver/hw/darwin/quartz/XDarwinStartup.c | 164 + .../Xserver/hw/darwin/quartz/XDarwinStartup.man | 75 + nx-X11/programs/Xserver/hw/darwin/quartz/XServer.h | 138 + nx-X11/programs/Xserver/hw/darwin/quartz/XServer.m | 1539 +++++ nx-X11/programs/Xserver/hw/darwin/quartz/applewm.c | 722 +++ .../programs/Xserver/hw/darwin/quartz/applewmExt.h | 85 + .../programs/Xserver/hw/darwin/quartz/cr/Imakefile | 35 + .../programs/Xserver/hw/darwin/quartz/cr/XView.h | 42 + .../programs/Xserver/hw/darwin/quartz/cr/XView.m | 74 + nx-X11/programs/Xserver/hw/darwin/quartz/cr/cr.h | 62 + .../Xserver/hw/darwin/quartz/cr/crAppleWM.m | 157 + .../programs/Xserver/hw/darwin/quartz/cr/crFrame.m | 439 ++ .../Xserver/hw/darwin/quartz/cr/crScreen.m | 381 ++ .../Xserver/hw/darwin/quartz/fullscreen/Imakefile | 19 + .../hw/darwin/quartz/fullscreen/fullscreen.c | 569 ++ .../hw/darwin/quartz/fullscreen/quartzCursor.c | 653 ++ .../hw/darwin/quartz/fullscreen/quartzCursor.h | 44 + .../programs/Xserver/hw/darwin/quartz/keysym2ucs.c | 909 +++ .../programs/Xserver/hw/darwin/quartz/keysym2ucs.h | 37 + .../Xserver/hw/darwin/quartz/pseudoramiX.c | 430 ++ .../Xserver/hw/darwin/quartz/pseudoramiX.h | 10 + nx-X11/programs/Xserver/hw/darwin/quartz/quartz.c | 426 ++ nx-X11/programs/Xserver/hw/darwin/quartz/quartz.h | 131 + .../Xserver/hw/darwin/quartz/quartzAudio.c | 342 ++ .../Xserver/hw/darwin/quartz/quartzAudio.h | 41 + .../Xserver/hw/darwin/quartz/quartzCocoa.m | 205 + .../Xserver/hw/darwin/quartz/quartzCommon.h | 108 + .../Xserver/hw/darwin/quartz/quartzCursor.c | 653 ++ .../Xserver/hw/darwin/quartz/quartzCursor.h | 43 + .../Xserver/hw/darwin/quartz/quartzKeyboard.c | 388 ++ .../Xserver/hw/darwin/quartz/quartzPasteboard.c | 150 + .../Xserver/hw/darwin/quartz/quartzPasteboard.h | 45 + .../Xserver/hw/darwin/quartz/quartzStartup.c | 291 + .../Xserver/hw/darwin/quartz/xpr/Imakefile | 35 + .../Xserver/hw/darwin/quartz/xpr/Xplugin.h | 591 ++ .../Xserver/hw/darwin/quartz/xpr/appledri.c | 350 ++ nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.c | 757 +++ nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.h | 129 + .../Xserver/hw/darwin/quartz/xpr/dristruct.h | 82 + .../programs/Xserver/hw/darwin/quartz/xpr/x-hash.c | 341 ++ .../programs/Xserver/hw/darwin/quartz/xpr/x-hash.h | 62 + .../programs/Xserver/hw/darwin/quartz/xpr/x-hook.c | 106 + .../programs/Xserver/hw/darwin/quartz/xpr/x-hook.h | 44 + .../programs/Xserver/hw/darwin/quartz/xpr/x-list.c | 335 ++ .../programs/Xserver/hw/darwin/quartz/xpr/x-list.h | 79 + nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xpr.h | 49 + .../Xserver/hw/darwin/quartz/xpr/xprAppleWM.c | 99 + .../Xserver/hw/darwin/quartz/xpr/xprCursor.c | 420 ++ .../Xserver/hw/darwin/quartz/xpr/xprFrame.c | 495 ++ .../Xserver/hw/darwin/quartz/xpr/xprScreen.c | 417 ++ nx-X11/programs/Xserver/hw/darwin/utils/Imakefile | 10 + nx-X11/programs/Xserver/hw/darwin/utils/README.txt | 111 + .../programs/Xserver/hw/darwin/utils/dumpkeymap.c | 1454 +++++ .../Xserver/hw/darwin/utils/dumpkeymap.man | 1004 ++++ nx-X11/programs/Xserver/hw/dmx/Imakefile | 125 + nx-X11/programs/Xserver/hw/dmx/Xdmx.man | 741 +++ nx-X11/programs/Xserver/hw/dmx/config/Canvas.c | 160 + nx-X11/programs/Xserver/hw/dmx/config/Canvas.h | 56 + nx-X11/programs/Xserver/hw/dmx/config/CanvasP.h | 66 + nx-X11/programs/Xserver/hw/dmx/config/Imakefile | 101 + nx-X11/programs/Xserver/hw/dmx/config/TODO | 7 + nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.c | 237 + nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.h | 45 + nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.c | 499 ++ nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.h | 65 + nx-X11/programs/Xserver/hw/dmx/config/dmxparse.c | 611 ++ nx-X11/programs/Xserver/hw/dmx/config/dmxparse.h | 298 + nx-X11/programs/Xserver/hw/dmx/config/dmxprint.c | 456 ++ nx-X11/programs/Xserver/hw/dmx/config/dmxprint.h | 44 + nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.c | 50 + nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.man | 41 + nx-X11/programs/Xserver/hw/dmx/config/parser.y | 226 + nx-X11/programs/Xserver/hw/dmx/config/scanner.l | 183 + nx-X11/programs/Xserver/hw/dmx/config/test-a.in | 1 + nx-X11/programs/Xserver/hw/dmx/config/test-a.out | 2 + nx-X11/programs/Xserver/hw/dmx/config/test-b.in | 1 + nx-X11/programs/Xserver/hw/dmx/config/test-b.out | 1 + nx-X11/programs/Xserver/hw/dmx/config/test-c.in | 1 + nx-X11/programs/Xserver/hw/dmx/config/test-c.out | 2 + nx-X11/programs/Xserver/hw/dmx/config/test-d.in | 1 + nx-X11/programs/Xserver/hw/dmx/config/test-d.out | 2 + nx-X11/programs/Xserver/hw/dmx/config/test-e.in | 1 + nx-X11/programs/Xserver/hw/dmx/config/test-e.out | 2 + nx-X11/programs/Xserver/hw/dmx/config/test-f.in | 2 + nx-X11/programs/Xserver/hw/dmx/config/test-f.out | Bin 0 -> 69 bytes nx-X11/programs/Xserver/hw/dmx/config/test-g.in | 4 + nx-X11/programs/Xserver/hw/dmx/config/test-g.out | 4 + nx-X11/programs/Xserver/hw/dmx/config/test-h.in | 7 + nx-X11/programs/Xserver/hw/dmx/config/test-h.out | 7 + nx-X11/programs/Xserver/hw/dmx/config/test-i.in | 3 + nx-X11/programs/Xserver/hw/dmx/config/test-i.out | 3 + nx-X11/programs/Xserver/hw/dmx/config/test-j.in | 13 + nx-X11/programs/Xserver/hw/dmx/config/test-j.out | 11 + nx-X11/programs/Xserver/hw/dmx/config/test-k.in | 3 + nx-X11/programs/Xserver/hw/dmx/config/test-k.out | 3 + nx-X11/programs/Xserver/hw/dmx/config/test-l.in | 12 + nx-X11/programs/Xserver/hw/dmx/config/test-l.out | 12 + nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.c | 58 + nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.man | 95 + nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.c | 1192 ++++ .../programs/Xserver/hw/dmx/config/xdmxconfig.man | 63 + nx-X11/programs/Xserver/hw/dmx/dmx.h | 374 ++ nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.c | 606 ++ nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.h | 64 + nx-X11/programs/Xserver/hw/dmx/dmxcb.c | 224 + nx-X11/programs/Xserver/hw/dmx/dmxcb.h | 54 + nx-X11/programs/Xserver/hw/dmx/dmxclient.h | 152 + nx-X11/programs/Xserver/hw/dmx/dmxcmap.c | 220 + nx-X11/programs/Xserver/hw/dmx/dmxcmap.h | 71 + nx-X11/programs/Xserver/hw/dmx/dmxcursor.c | 926 +++ nx-X11/programs/Xserver/hw/dmx/dmxcursor.h | 70 + nx-X11/programs/Xserver/hw/dmx/dmxdpms.c | 213 + nx-X11/programs/Xserver/hw/dmx/dmxdpms.h | 43 + nx-X11/programs/Xserver/hw/dmx/dmxextension.c | 1497 +++++ nx-X11/programs/Xserver/hw/dmx/dmxextension.h | 119 + nx-X11/programs/Xserver/hw/dmx/dmxfont.c | 559 ++ nx-X11/programs/Xserver/hw/dmx/dmxfont.h | 60 + nx-X11/programs/Xserver/hw/dmx/dmxgc.c | 424 ++ nx-X11/programs/Xserver/hw/dmx/dmxgc.h | 90 + nx-X11/programs/Xserver/hw/dmx/dmxgcops.c | 602 ++ nx-X11/programs/Xserver/hw/dmx/dmxgcops.h | 96 + nx-X11/programs/Xserver/hw/dmx/dmxinit.c | 1062 ++++ nx-X11/programs/Xserver/hw/dmx/dmxinit.h | 51 + nx-X11/programs/Xserver/hw/dmx/dmxinput.c | 105 + nx-X11/programs/Xserver/hw/dmx/dmxinput.h | 163 + nx-X11/programs/Xserver/hw/dmx/dmxlog.c | 351 ++ nx-X11/programs/Xserver/hw/dmx/dmxlog.h | 79 + nx-X11/programs/Xserver/hw/dmx/dmxpict.c | 1298 ++++ nx-X11/programs/Xserver/hw/dmx/dmxpict.h | 133 + nx-X11/programs/Xserver/hw/dmx/dmxpixmap.c | 252 + nx-X11/programs/Xserver/hw/dmx/dmxpixmap.h | 67 + nx-X11/programs/Xserver/hw/dmx/dmxprop.c | 348 ++ nx-X11/programs/Xserver/hw/dmx/dmxprop.h | 47 + nx-X11/programs/Xserver/hw/dmx/dmxscrinit.c | 566 ++ nx-X11/programs/Xserver/hw/dmx/dmxscrinit.h | 52 + nx-X11/programs/Xserver/hw/dmx/dmxshadow.c | 72 + nx-X11/programs/Xserver/hw/dmx/dmxshadow.h | 47 + nx-X11/programs/Xserver/hw/dmx/dmxstat.c | 223 + nx-X11/programs/Xserver/hw/dmx/dmxstat.h | 56 + nx-X11/programs/Xserver/hw/dmx/dmxsync.c | 194 + nx-X11/programs/Xserver/hw/dmx/dmxsync.h | 44 + nx-X11/programs/Xserver/hw/dmx/dmxvisual.c | 141 + nx-X11/programs/Xserver/hw/dmx/dmxvisual.h | 48 + nx-X11/programs/Xserver/hw/dmx/dmxwindow.c | 1085 ++++ nx-X11/programs/Xserver/hw/dmx/dmxwindow.h | 149 + nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec-v1.txt | 458 ++ nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec.txt | 875 +++ nx-X11/programs/Xserver/hw/dmx/doc/Imakefile | 10 + nx-X11/programs/Xserver/hw/dmx/doc/Makefile.linux | 42 + nx-X11/programs/Xserver/hw/dmx/doc/dmx.sgml | 2778 +++++++++ nx-X11/programs/Xserver/hw/dmx/doc/dmx.txt | 2989 ++++++++++ nx-X11/programs/Xserver/hw/dmx/doc/doxygen.conf | 1090 ++++ nx-X11/programs/Xserver/hw/dmx/doc/doxygen.css | 49 + nx-X11/programs/Xserver/hw/dmx/doc/doxygen.foot | 12 + nx-X11/programs/Xserver/hw/dmx/doc/doxygen.head | 8 + .../Xserver/hw/dmx/doc/html/ChkNotMaskEv_8c.html | 76 + .../hw/dmx/doc/html/ChkNotMaskEv_8h-source.html | 60 + .../Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h.html | 77 + .../Xserver/hw/dmx/doc/html/annotated.html | 98 + .../programs/Xserver/hw/dmx/doc/html/classes.html | 26 + .../Xserver/hw/dmx/doc/html/dmx_8h-source.html | 276 + .../programs/Xserver/hw/dmx/doc/html/dmx_8h.html | 532 ++ .../hw/dmx/doc/html/dmx__glxvisuals_8h-source.html | 85 + .../Xserver/hw/dmx/doc/html/dmxarg_8c.html | 239 + .../Xserver/hw/dmx/doc/html/dmxarg_8h-source.html | 69 + .../Xserver/hw/dmx/doc/html/dmxarg_8h.html | 235 + .../Xserver/hw/dmx/doc/html/dmxbackend_8c.html | 427 ++ .../hw/dmx/doc/html/dmxbackend_8h-source.html | 75 + .../Xserver/hw/dmx/doc/html/dmxbackend_8h.html | 411 ++ .../programs/Xserver/hw/dmx/doc/html/dmxcb_8c.html | 184 + .../Xserver/hw/dmx/doc/html/dmxcb_8h-source.html | 70 + .../programs/Xserver/hw/dmx/doc/html/dmxcb_8h.html | 209 + .../hw/dmx/doc/html/dmxclient_8h-source.html | 168 + .../Xserver/hw/dmx/doc/html/dmxclient_8h.html | 48 + .../Xserver/hw/dmx/doc/html/dmxcmap_8c.html | 265 + .../Xserver/hw/dmx/doc/html/dmxcmap_8h-source.html | 86 + .../Xserver/hw/dmx/doc/html/dmxcmap_8h.html | 408 ++ .../Xserver/hw/dmx/doc/html/dmxcommon_8c.html | 701 +++ .../hw/dmx/doc/html/dmxcommon_8h-source.html | 151 + .../Xserver/hw/dmx/doc/html/dmxcommon_8h.html | 665 +++ .../Xserver/hw/dmx/doc/html/dmxcompat_8c.html | 68 + .../hw/dmx/doc/html/dmxcompat_8h-source.html | 61 + .../Xserver/hw/dmx/doc/html/dmxcompat_8h.html | 62 + .../Xserver/hw/dmx/doc/html/dmxconfig_8c.html | 402 ++ .../hw/dmx/doc/html/dmxconfig_8h-source.html | 84 + .../Xserver/hw/dmx/doc/html/dmxconfig_8h.html | 248 + .../Xserver/hw/dmx/doc/html/dmxconsole_8c.html | 498 ++ .../hw/dmx/doc/html/dmxconsole_8h-source.html | 79 + .../Xserver/hw/dmx/doc/html/dmxconsole_8h.html | 488 ++ .../Xserver/hw/dmx/doc/html/dmxcursor_8c.html | 471 ++ .../hw/dmx/doc/html/dmxcursor_8h-source.html | 86 + .../Xserver/hw/dmx/doc/html/dmxcursor_8h.html | 498 ++ .../Xserver/hw/dmx/doc/html/dmxdetach_8c.html | 70 + .../Xserver/hw/dmx/doc/html/dmxdpms_8c.html | 128 + .../Xserver/hw/dmx/doc/html/dmxdpms_8h-source.html | 62 + .../Xserver/hw/dmx/doc/html/dmxdpms_8h.html | 124 + .../Xserver/hw/dmx/doc/html/dmxdummy_8c.html | 111 + .../hw/dmx/doc/html/dmxdummy_8h-source.html | 63 + .../Xserver/hw/dmx/doc/html/dmxdummy_8h.html | 111 + .../programs/Xserver/hw/dmx/doc/html/dmxeq_8c.html | 269 + .../Xserver/hw/dmx/doc/html/dmxeq_8h-source.html | 61 + .../programs/Xserver/hw/dmx/doc/html/dmxeq_8h.html | 63 + .../Xserver/hw/dmx/doc/html/dmxevents_8c.html | 284 + .../hw/dmx/doc/html/dmxevents_8h-source.html | 66 + .../Xserver/hw/dmx/doc/html/dmxevents_8h.html | 233 + .../Xserver/hw/dmx/doc/html/dmxext_8h-source.html | 197 + .../Xserver/hw/dmx/doc/html/dmxext_8h.html | 926 +++ .../Xserver/hw/dmx/doc/html/dmxextension_8c.html | 433 ++ .../hw/dmx/doc/html/dmxextension_8h-source.html | 131 + .../Xserver/hw/dmx/doc/html/dmxextension_8h.html | 426 ++ .../Xserver/hw/dmx/doc/html/dmxfont_8c.html | 257 + .../Xserver/hw/dmx/doc/html/dmxfont_8h-source.html | 78 + .../Xserver/hw/dmx/doc/html/dmxfont_8h.html | 333 ++ .../programs/Xserver/hw/dmx/doc/html/dmxgc_8c.html | 456 ++ .../Xserver/hw/dmx/doc/html/dmxgc_8h-source.html | 106 + .../programs/Xserver/hw/dmx/doc/html/dmxgc_8h.html | 561 ++ .../Xserver/hw/dmx/doc/html/dmxgcops_8c.html | 1476 +++++ .../hw/dmx/doc/html/dmxgcops_8h-source.html | 115 + .../Xserver/hw/dmx/doc/html/dmxgcops_8h.html | 1469 +++++ .../Xserver/hw/dmx/doc/html/dmxinit_8c.html | 709 +++ .../Xserver/hw/dmx/doc/html/dmxinit_8h-source.html | 70 + .../Xserver/hw/dmx/doc/html/dmxinit_8h.html | 30 + .../Xserver/hw/dmx/doc/html/dmxinput_8c.html | 185 + .../hw/dmx/doc/html/dmxinput_8h-source.html | 146 + .../Xserver/hw/dmx/doc/html/dmxinput_8h.html | 534 ++ .../Xserver/hw/dmx/doc/html/dmxinputinit_8c.html | 477 ++ .../hw/dmx/doc/html/dmxinputinit_8h-source.html | 259 + .../Xserver/hw/dmx/doc/html/dmxinputinit_8h.html | 406 ++ .../Xserver/hw/dmx/doc/html/dmxlog_8c.html | 602 ++ .../Xserver/hw/dmx/doc/html/dmxlog_8h-source.html | 91 + .../Xserver/hw/dmx/doc/html/dmxlog_8h.html | 616 ++ .../Xserver/hw/dmx/doc/html/dmxmap_8c.html | 150 + .../Xserver/hw/dmx/doc/html/dmxmap_8h-source.html | 62 + .../Xserver/hw/dmx/doc/html/dmxmap_8h.html | 148 + .../Xserver/hw/dmx/doc/html/dmxmotion_8c.html | 181 + .../hw/dmx/doc/html/dmxmotion_8h-source.html | 69 + .../Xserver/hw/dmx/doc/html/dmxmotion_8h.html | 180 + .../Xserver/hw/dmx/doc/html/dmxparse_8c.html | 74 + .../hw/dmx/doc/html/dmxparse_8h-source.html | 303 + .../Xserver/hw/dmx/doc/html/dmxparse_8h.html | 775 +++ .../Xserver/hw/dmx/doc/html/dmxpict_8c.html | 1184 ++++ .../Xserver/hw/dmx/doc/html/dmxpict_8h-source.html | 141 + .../Xserver/hw/dmx/doc/html/dmxpict_8h.html | 1418 +++++ .../Xserver/hw/dmx/doc/html/dmxpixmap_8c.html | 240 + .../hw/dmx/doc/html/dmxpixmap_8h-source.html | 83 + .../Xserver/hw/dmx/doc/html/dmxpixmap_8h.html | 351 ++ .../Xserver/hw/dmx/doc/html/dmxprint_8c.html | 119 + .../hw/dmx/doc/html/dmxprint_8h-source.html | 63 + .../Xserver/hw/dmx/doc/html/dmxprint_8h.html | 111 + .../Xserver/hw/dmx/doc/html/dmxprop_8c.html | 235 + .../Xserver/hw/dmx/doc/html/dmxprop_8h-source.html | 66 + .../Xserver/hw/dmx/doc/html/dmxprop_8h.html | 136 + .../hw/dmx/doc/html/dmxproto_8h-source.html | 431 ++ .../Xserver/hw/dmx/doc/html/dmxproto_8h.html | 89 + .../Xserver/hw/dmx/doc/html/dmxscrinit_8c.html | 378 ++ .../hw/dmx/doc/html/dmxscrinit_8h-source.html | 70 + .../Xserver/hw/dmx/doc/html/dmxscrinit_8h.html | 181 + .../Xserver/hw/dmx/doc/html/dmxshadow_8c.html | 71 + .../hw/dmx/doc/html/dmxshadow_8h-source.html | 66 + .../Xserver/hw/dmx/doc/html/dmxshadow_8h.html | 73 + .../Xserver/hw/dmx/doc/html/dmxsigio_8c.html | 230 + .../hw/dmx/doc/html/dmxsigio_8h-source.html | 65 + .../Xserver/hw/dmx/doc/html/dmxsigio_8h.html | 226 + .../Xserver/hw/dmx/doc/html/dmxstat_8c.html | 274 + .../Xserver/hw/dmx/doc/html/dmxstat_8h-source.html | 74 + .../Xserver/hw/dmx/doc/html/dmxstat_8h.html | 364 ++ .../Xserver/hw/dmx/doc/html/dmxsync_8c.html | 139 + .../Xserver/hw/dmx/doc/html/dmxsync_8h-source.html | 63 + .../Xserver/hw/dmx/doc/html/dmxsync_8h.html | 136 + .../Xserver/hw/dmx/doc/html/dmxvisual_8c.html | 151 + .../hw/dmx/doc/html/dmxvisual_8h-source.html | 67 + .../Xserver/hw/dmx/doc/html/dmxvisual_8h.html | 152 + .../Xserver/hw/dmx/doc/html/dmxwindow_8c.html | 865 +++ .../hw/dmx/doc/html/dmxwindow_8h-source.html | 165 + .../Xserver/hw/dmx/doc/html/dmxwindow_8h.html | 969 +++ .../Xserver/hw/dmx/doc/html/dmxxinput_8c.html | 396 ++ .../programs/Xserver/hw/dmx/doc/html/doxygen.css | 49 + .../programs/Xserver/hw/dmx/doc/html/doxygen.png | Bin 0 -> 2352 bytes nx-X11/programs/Xserver/hw/dmx/doc/html/files.html | 120 + .../programs/Xserver/hw/dmx/doc/html/ftv2blank.png | Bin 0 -> 174 bytes .../programs/Xserver/hw/dmx/doc/html/ftv2doc.png | Bin 0 -> 255 bytes .../Xserver/hw/dmx/doc/html/ftv2folderclosed.png | Bin 0 -> 259 bytes .../Xserver/hw/dmx/doc/html/ftv2folderopen.png | Bin 0 -> 261 bytes .../Xserver/hw/dmx/doc/html/ftv2lastnode.png | Bin 0 -> 233 bytes .../programs/Xserver/hw/dmx/doc/html/ftv2link.png | Bin 0 -> 358 bytes .../Xserver/hw/dmx/doc/html/ftv2mlastnode.png | Bin 0 -> 160 bytes .../programs/Xserver/hw/dmx/doc/html/ftv2mnode.png | Bin 0 -> 194 bytes .../programs/Xserver/hw/dmx/doc/html/ftv2node.png | Bin 0 -> 235 bytes .../Xserver/hw/dmx/doc/html/ftv2plastnode.png | Bin 0 -> 165 bytes .../programs/Xserver/hw/dmx/doc/html/ftv2pnode.png | Bin 0 -> 200 bytes .../Xserver/hw/dmx/doc/html/ftv2vertline.png | Bin 0 -> 229 bytes .../Xserver/hw/dmx/doc/html/functions.html | 237 + .../Xserver/hw/dmx/doc/html/functions_vars.html | 237 + .../programs/Xserver/hw/dmx/doc/html/globals.html | 522 ++ .../Xserver/hw/dmx/doc/html/globals_defs.html | 47 + .../Xserver/hw/dmx/doc/html/globals_enum.html | 32 + .../Xserver/hw/dmx/doc/html/globals_eval.html | 41 + .../Xserver/hw/dmx/doc/html/globals_func.html | 388 ++ .../Xserver/hw/dmx/doc/html/globals_type.html | 96 + .../Xserver/hw/dmx/doc/html/globals_vars.html | 56 + nx-X11/programs/Xserver/hw/dmx/doc/html/index.html | 8 + .../Xserver/hw/dmx/doc/html/lib_2dmx_2dmx_8c.html | 894 +++ .../Xserver/hw/dmx/doc/html/lnx-keyboard_8c.html | 511 ++ .../hw/dmx/doc/html/lnx-keyboard_8h-source.html | 83 + .../Xserver/hw/dmx/doc/html/lnx-keyboard_8h.html | 388 ++ .../Xserver/hw/dmx/doc/html/lnx-ms_8c.html | 352 ++ .../Xserver/hw/dmx/doc/html/lnx-ms_8h-source.html | 75 + .../Xserver/hw/dmx/doc/html/lnx-ms_8h.html | 288 + .../Xserver/hw/dmx/doc/html/lnx-ps2_8c.html | 352 ++ .../Xserver/hw/dmx/doc/html/lnx-ps2_8h-source.html | 75 + .../Xserver/hw/dmx/doc/html/lnx-ps2_8h.html | 288 + nx-X11/programs/Xserver/hw/dmx/doc/html/main.html | 26 + .../doc/html/programs_2Xserver_2Xext_2dmx_8c.html | 71 + .../hw/dmx/doc/html/structDMXConfigCmdStruct.html | 30 + .../hw/dmx/doc/html/structDMXConfigListStruct.html | 30 + .../dmx/doc/html/structDMXDesktopAttributes.html | 32 + .../doc/html/structDMXDesktopAttributesRec.html | 32 + .../hw/dmx/doc/html/structDMXInputAttributes.html | 32 + .../dmx/doc/html/structDMXInputAttributesRec.html | 32 + .../hw/dmx/doc/html/structDMXScreenAttributes.html | 32 + .../dmx/doc/html/structDMXScreenAttributesRec.html | 32 + .../hw/dmx/doc/html/structDMXWindowAttributes.html | 32 + .../dmx/doc/html/structDMXWindowAttributesRec.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigComment.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigDisplay.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigEntry.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigFullDim.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigNumber.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigOption.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigPair.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigParam.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigPartDim.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigString.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigSub.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigToken.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigVirtual.html | 32 + .../hw/dmx/doc/html/struct__DMXConfigWall.html | 32 + .../hw/dmx/doc/html/struct__DMXEventMap.html | 82 + .../hw/dmx/doc/html/struct__DMXInputInfo.html | 490 ++ .../hw/dmx/doc/html/struct__DMXLocalInitInfo.html | 778 +++ .../hw/dmx/doc/html/struct__DMXLocalInputInfo.html | 996 ++++ .../hw/dmx/doc/html/struct__DMXScreenInfo.html | 1330 +++++ .../hw/dmx/doc/html/struct__DMXStatAvg.html | 30 + .../hw/dmx/doc/html/struct__DMXStatInfo.html | 30 + .../Xserver/hw/dmx/doc/html/struct__Event.html | 104 + .../hw/dmx/doc/html/struct__EventQueue.html | 224 + .../Xserver/hw/dmx/doc/html/struct__dmxArg.html | 104 + .../hw/dmx/doc/html/struct__dmxColormapPriv.html | 32 + .../hw/dmx/doc/html/struct__dmxCursorPriv.html | 32 + .../hw/dmx/doc/html/struct__dmxFontPriv.html | 32 + .../Xserver/hw/dmx/doc/html/struct__dmxGCPriv.html | 32 + .../hw/dmx/doc/html/struct__dmxGlyphPriv.html | 58 + .../hw/dmx/doc/html/struct__dmxPictPriv.html | 82 + .../hw/dmx/doc/html/struct__dmxPixPriv.html | 32 + .../hw/dmx/doc/html/struct__dmxWinPriv.html | 32 + .../Xserver/hw/dmx/doc/html/struct__myPrivate.html | 272 + .../hw/dmx/doc/html/structdmxGlxVisualPrivate.html | 32 + .../hw/dmx/doc/html/structxDMXAddInputReply.html | 32 + .../hw/dmx/doc/html/structxDMXAddInputReq.html | 32 + .../hw/dmx/doc/html/structxDMXAddScreenReply.html | 32 + .../hw/dmx/doc/html/structxDMXAddScreenReq.html | 32 + .../structxDMXChangeDesktopAttributesReply.html | 32 + .../html/structxDMXChangeDesktopAttributesReq.html | 32 + .../structxDMXChangeScreensAttributesReply.html | 32 + .../html/structxDMXChangeScreensAttributesReq.html | 32 + .../html/structxDMXForceWindowCreationReply.html | 32 + .../doc/html/structxDMXForceWindowCreationReq.html | 32 + .../html/structxDMXGetDesktopAttributesReply.html | 32 + .../html/structxDMXGetDesktopAttributesReq.html | 32 + .../html/structxDMXGetInputAttributesReply.html | 32 + .../doc/html/structxDMXGetInputAttributesReq.html | 32 + .../dmx/doc/html/structxDMXGetInputCountReply.html | 32 + .../dmx/doc/html/structxDMXGetInputCountReq.html | 32 + .../html/structxDMXGetScreenAttributesReply.html | 32 + .../doc/html/structxDMXGetScreenAttributesReq.html | 32 + .../doc/html/structxDMXGetScreenCountReply.html | 32 + .../dmx/doc/html/structxDMXGetScreenCountReq.html | 32 + .../html/structxDMXGetWindowAttributesReply.html | 32 + .../doc/html/structxDMXGetWindowAttributesReq.html | 32 + .../dmx/doc/html/structxDMXQueryVersionReply.html | 32 + .../hw/dmx/doc/html/structxDMXQueryVersionReq.html | 32 + .../dmx/doc/html/structxDMXRemoveInputReply.html | 32 + .../hw/dmx/doc/html/structxDMXRemoveInputReq.html | 32 + .../dmx/doc/html/structxDMXRemoveScreenReply.html | 32 + .../hw/dmx/doc/html/structxDMXRemoveScreenReq.html | 32 + .../hw/dmx/doc/html/structxDMXSyncReply.html | 32 + .../Xserver/hw/dmx/doc/html/structxDMXSyncReq.html | 32 + nx-X11/programs/Xserver/hw/dmx/doc/html/tree.html | 295 + .../Xserver/hw/dmx/doc/html/usb-common_8c.html | 222 + .../hw/dmx/doc/html/usb-common_8h-source.html | 74 + .../Xserver/hw/dmx/doc/html/usb-common_8h.html | 167 + .../Xserver/hw/dmx/doc/html/usb-keyboard_8c.html | 231 + .../hw/dmx/doc/html/usb-keyboard_8h-source.html | 68 + .../Xserver/hw/dmx/doc/html/usb-keyboard_8h.html | 174 + .../Xserver/hw/dmx/doc/html/usb-mouse_8c.html | 190 + .../hw/dmx/doc/html/usb-mouse_8h-source.html | 68 + .../Xserver/hw/dmx/doc/html/usb-mouse_8h.html | 134 + .../Xserver/hw/dmx/doc/html/usb-other_8c.html | 191 + .../hw/dmx/doc/html/usb-other_8h-source.html | 68 + .../Xserver/hw/dmx/doc/html/usb-other_8h.html | 134 + .../hw/dmx/doc/html/usb-private_8h-source.html | 131 + .../Xserver/hw/dmx/doc/html/usb-private_8h.html | 41 + nx-X11/programs/Xserver/hw/dmx/doc/scaled.sgml | 707 +++ nx-X11/programs/Xserver/hw/dmx/doc/scaled.txt | 579 ++ nx-X11/programs/Xserver/hw/dmx/examples/Imakefile | 56 + .../programs/Xserver/hw/dmx/examples/dmxaddinput.c | 84 + .../Xserver/hw/dmx/examples/dmxaddscreen.c | 106 + .../programs/Xserver/hw/dmx/examples/dmxreconfig.c | 163 + .../programs/Xserver/hw/dmx/examples/dmxresize.c | 105 + .../programs/Xserver/hw/dmx/examples/dmxrminput.c | 79 + .../programs/Xserver/hw/dmx/examples/dmxrmscreen.c | 81 + .../programs/Xserver/hw/dmx/examples/dmxwininfo.c | 497 ++ nx-X11/programs/Xserver/hw/dmx/examples/ev.c | 183 + nx-X11/programs/Xserver/hw/dmx/examples/evi.c | 87 + nx-X11/programs/Xserver/hw/dmx/examples/res.c | 100 + nx-X11/programs/Xserver/hw/dmx/examples/xbell.c | 102 + nx-X11/programs/Xserver/hw/dmx/examples/xdmx.c | 240 + nx-X11/programs/Xserver/hw/dmx/examples/xinput.c | 319 + nx-X11/programs/Xserver/hw/dmx/examples/xled.c | 125 + nx-X11/programs/Xserver/hw/dmx/examples/xtest.c | 76 + nx-X11/programs/Xserver/hw/dmx/glxProxy/Imakefile | 52 + nx-X11/programs/Xserver/hw/dmx/glxProxy/compsize.c | 564 ++ .../programs/Xserver/hw/dmx/glxProxy/g_disptab.c | 612 ++ .../programs/Xserver/hw/dmx/glxProxy/g_disptab.h | 676 +++ .../Xserver/hw/dmx/glxProxy/g_renderswap.c | 2360 ++++++++ nx-X11/programs/Xserver/hw/dmx/glxProxy/global.c | 77 + nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmds.c | 3636 ++++++++++++ .../programs/Xserver/hw/dmx/glxProxy/glxcmdsswap.c | 1059 ++++ .../programs/Xserver/hw/dmx/glxProxy/glxcontext.h | 117 + .../programs/Xserver/hw/dmx/glxProxy/glxdrawable.h | 124 + nx-X11/programs/Xserver/hw/dmx/glxProxy/glxerror.h | 58 + nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.c | 512 ++ nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.h | 98 + .../programs/Xserver/hw/dmx/glxProxy/glxfbconfig.c | 111 + .../programs/Xserver/hw/dmx/glxProxy/glxfbconfig.h | 43 + .../programs/Xserver/hw/dmx/glxProxy/glxscreens.c | 390 ++ .../programs/Xserver/hw/dmx/glxProxy/glxscreens.h | 63 + .../programs/Xserver/hw/dmx/glxProxy/glxserver.h | 327 + .../programs/Xserver/hw/dmx/glxProxy/glxsingle.c | 1013 ++++ .../programs/Xserver/hw/dmx/glxProxy/glxsingle.h | 59 + nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.c | 539 ++ nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.h | 47 + nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.c | 121 + nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.h | 54 + .../programs/Xserver/hw/dmx/glxProxy/glxvendor.c | 583 ++ .../programs/Xserver/hw/dmx/glxProxy/glxvendor.h | 55 + .../programs/Xserver/hw/dmx/glxProxy/glxvisuals.c | 542 ++ .../programs/Xserver/hw/dmx/glxProxy/glxvisuals.h | 55 + .../programs/Xserver/hw/dmx/glxProxy/render2swap.c | 348 ++ .../Xserver/hw/dmx/glxProxy/renderpixswap.c | 390 ++ nx-X11/programs/Xserver/hw/dmx/glxProxy/unpack.h | 234 + .../programs/Xserver/hw/dmx/input/ChkNotMaskEv.c | 108 + .../programs/Xserver/hw/dmx/input/ChkNotMaskEv.h | 41 + nx-X11/programs/Xserver/hw/dmx/input/Imakefile | 46 + nx-X11/programs/Xserver/hw/dmx/input/dmxarg.c | 176 + nx-X11/programs/Xserver/hw/dmx/input/dmxarg.h | 50 + nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.c | 608 ++ nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.h | 57 + nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.c | 674 +++ nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.h | 133 + nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.c | 1023 ++++ nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.h | 60 + nx-X11/programs/Xserver/hw/dmx/input/dmxdetach.c | 59 + nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.c | 87 + nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.h | 44 + nx-X11/programs/Xserver/hw/dmx/input/dmxeq.c | 309 + nx-X11/programs/Xserver/hw/dmx/input/dmxeq.h | 44 + nx-X11/programs/Xserver/hw/dmx/input/dmxevents.c | 716 +++ nx-X11/programs/Xserver/hw/dmx/input/dmxevents.h | 47 + .../programs/Xserver/hw/dmx/input/dmxinputinit.c | 1298 ++++ .../programs/Xserver/hw/dmx/input/dmxinputinit.h | 294 + nx-X11/programs/Xserver/hw/dmx/input/dmxmap.c | 122 + nx-X11/programs/Xserver/hw/dmx/input/dmxmap.h | 43 + nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.c | 144 + nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.h | 50 + nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.c | 234 + nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.h | 46 + nx-X11/programs/Xserver/hw/dmx/input/dmxxinput.c | 156 + .../programs/Xserver/hw/dmx/input/lnx-keyboard.c | 975 +++ .../programs/Xserver/hw/dmx/input/lnx-keyboard.h | 64 + nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.c | 323 + nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.h | 56 + nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.c | 291 + nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.h | 56 + nx-X11/programs/Xserver/hw/dmx/input/usb-common.c | 383 ++ nx-X11/programs/Xserver/hw/dmx/input/usb-common.h | 56 + .../programs/Xserver/hw/dmx/input/usb-keyboard.c | 442 ++ .../programs/Xserver/hw/dmx/input/usb-keyboard.h | 49 + nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.c | 127 + nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.h | 49 + nx-X11/programs/Xserver/hw/dmx/input/usb-other.c | 162 + nx-X11/programs/Xserver/hw/dmx/input/usb-other.h | 49 + nx-X11/programs/Xserver/hw/dmx/input/usb-private.h | 118 + nx-X11/programs/Xserver/hw/kdrive/README | 7 + nx-X11/programs/Xserver/hw/sun/Imakefile | 90 + nx-X11/programs/Xserver/hw/sun/README | 118 + nx-X11/programs/Xserver/hw/sun/Xsun.man | 176 + nx-X11/programs/Xserver/hw/sun/circleset.h | 136 + nx-X11/programs/Xserver/hw/sun/constype.c | 216 + nx-X11/programs/Xserver/hw/sun/constype.man | 80 + nx-X11/programs/Xserver/hw/sun/kbd_mode.c | 155 + nx-X11/programs/Xserver/hw/sun/kbd_mode.man | 53 + nx-X11/programs/Xserver/hw/sun/sun.h | 446 ++ nx-X11/programs/Xserver/hw/sun/sunCfb.c | 517 ++ nx-X11/programs/Xserver/hw/sun/sunCfb24.c | 139 + nx-X11/programs/Xserver/hw/sun/sunCursor.c | 281 + nx-X11/programs/Xserver/hw/sun/sunFbs.c | 259 + nx-X11/programs/Xserver/hw/sun/sunGX.c | 2906 +++++++++ nx-X11/programs/Xserver/hw/sun/sunGX.h | 238 + nx-X11/programs/Xserver/hw/sun/sunInit.c | 960 +++ nx-X11/programs/Xserver/hw/sun/sunIo.c | 305 + nx-X11/programs/Xserver/hw/sun/sunKbd.c | 1071 ++++ nx-X11/programs/Xserver/hw/sun/sunKeyMap.c | 5797 ++++++++++++++++++ nx-X11/programs/Xserver/hw/sun/sunMfb.c | 108 + nx-X11/programs/Xserver/hw/sun/sunMouse.c | 399 ++ nx-X11/programs/Xserver/hw/sun/sunMultiDepth.c | 277 + nx-X11/programs/Xserver/hw/sunLynx/Imakefile | 78 + nx-X11/programs/Xserver/hw/sunLynx/btreg.h | 81 + nx-X11/programs/Xserver/hw/sunLynx/btvar.h | 74 + nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h | 206 + nx-X11/programs/Xserver/hw/sunLynx/fbio.h | 186 + nx-X11/programs/Xserver/hw/sunLynx/patch.Console | 428 ++ .../Xserver/hw/sunLynx/patch.Console-2.4.0 | 493 ++ nx-X11/programs/Xserver/hw/sunLynx/sun.h | 486 ++ nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c | 372 ++ nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c | 292 + nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c | 648 ++ nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c | 389 ++ nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c | 1080 ++++ nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c | 649 ++ nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c | 509 ++ nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h | 88 + nx-X11/programs/Xserver/hw/vfb/Imakefile | 71 + nx-X11/programs/Xserver/hw/vfb/InitInput.c | 344 ++ nx-X11/programs/Xserver/hw/vfb/InitOutput.c | 1046 ++++ nx-X11/programs/Xserver/hw/vfb/Xvfb.man | 132 + nx-X11/programs/Xserver/hw/vfb/lk201kbd.h | 159 + .../programs/Xserver/hw/xfree86/common/Imakefile | 275 + .../Xserver/hw/xfree86/common/atKeynames.h | 298 + .../programs/Xserver/hw/xfree86/common/compiler.h | 1863 ++++++ nx-X11/programs/Xserver/hw/xfree86/common/fourcc.h | 161 + .../Xserver/hw/xfree86/common/modeline2c.pl | 110 + nx-X11/programs/Xserver/hw/xfree86/common/scoasm.h | 143 + nx-X11/programs/Xserver/hw/xfree86/common/xf86.h | 447 ++ .../Xserver/hw/xfree86/common/xf86AutoConfig.c | 368 ++ .../programs/Xserver/hw/xfree86/common/xf86Bus.c | 3317 +++++++++++ .../programs/Xserver/hw/xfree86/common/xf86Bus.h | 162 + .../Xserver/hw/xfree86/common/xf86Config.c | 2740 +++++++++ .../Xserver/hw/xfree86/common/xf86Config.h | 63 + .../Xserver/hw/xfree86/common/xf86Configure.c | 1049 ++++ .../Xserver/hw/xfree86/common/xf86Cursor.c | 788 +++ .../programs/Xserver/hw/xfree86/common/xf86DGA.c | 1267 ++++ .../programs/Xserver/hw/xfree86/common/xf86DPMS.c | 222 + .../programs/Xserver/hw/xfree86/common/xf86Debug.c | 197 + .../Xserver/hw/xfree86/common/xf86DefModes.c | 160 + .../Xserver/hw/xfree86/common/xf86DoProbe.c | 129 + .../Xserver/hw/xfree86/common/xf86DoScanPci.c | 130 + .../Xserver/hw/xfree86/common/xf86Events.c | 1865 ++++++ .../Xserver/hw/xfree86/common/xf86Globals.c | 254 + .../Xserver/hw/xfree86/common/xf86Helper.c | 2983 ++++++++++ .../Xserver/hw/xfree86/common/xf86InPriv.h | 48 + .../programs/Xserver/hw/xfree86/common/xf86Init.c | 2035 +++++++ nx-X11/programs/Xserver/hw/xfree86/common/xf86Io.c | 507 ++ .../programs/Xserver/hw/xfree86/common/xf86Kbd.c | 395 ++ .../Xserver/hw/xfree86/common/xf86KbdBSD.c | 1266 ++++ .../Xserver/hw/xfree86/common/xf86KbdLnx.c | 651 ++ .../Xserver/hw/xfree86/common/xf86KbdMach.c | 317 + .../Xserver/hw/xfree86/common/xf86Keymap.h | 455 ++ .../Xserver/hw/xfree86/common/xf86MiscExt.c | 656 ++ .../programs/Xserver/hw/xfree86/common/xf86Mode.c | 2185 +++++++ .../Xserver/hw/xfree86/common/xf86Module.h | 226 + .../programs/Xserver/hw/xfree86/common/xf86Opt.h | 114 + .../Xserver/hw/xfree86/common/xf86Option.c | 884 +++ nx-X11/programs/Xserver/hw/xfree86/common/xf86PM.c | 225 + .../Xserver/hw/xfree86/common/xf86PciInfo.h | 726 +++ .../programs/Xserver/hw/xfree86/common/xf86Priv.h | 228 + .../Xserver/hw/xfree86/common/xf86Privstr.h | 234 + .../programs/Xserver/hw/xfree86/common/xf86RandR.c | 438 ++ .../Xserver/hw/xfree86/common/xf86Resources.h | 140 + .../Xserver/hw/xfree86/common/xf86Versions.c | 81 + .../Xserver/hw/xfree86/common/xf86VidMode.c | 722 +++ .../programs/Xserver/hw/xfree86/common/xf86XKB.c | 82 + .../Xserver/hw/xfree86/common/xf86Xinput.c | 1513 +++++ .../Xserver/hw/xfree86/common/xf86Xinput.h | 220 + .../programs/Xserver/hw/xfree86/common/xf86cmap.c | 1123 ++++ .../programs/Xserver/hw/xfree86/common/xf86cmap.h | 76 + .../programs/Xserver/hw/xfree86/common/xf86fbBus.c | 97 + .../programs/Xserver/hw/xfree86/common/xf86fbman.c | 1445 +++++ .../programs/Xserver/hw/xfree86/common/xf86fbman.h | 227 + .../Xserver/hw/xfree86/common/xf86isaBus.c | 142 + .../programs/Xserver/hw/xfree86/common/xf86noBus.c | 75 + .../Xserver/hw/xfree86/common/xf86pciBus.c | 3506 +++++++++++ .../Xserver/hw/xfree86/common/xf86pciBus.h | 99 + .../Xserver/hw/xfree86/common/xf86sbusBus.c | 709 +++ .../Xserver/hw/xfree86/common/xf86sbusBus.h | 98 + .../programs/Xserver/hw/xfree86/common/xf86str.h | 1140 ++++ nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.c | 2050 +++++++ nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.h | 271 + .../programs/Xserver/hw/xfree86/common/xf86xvmc.c | 243 + .../programs/Xserver/hw/xfree86/common/xf86xvmc.h | 164 + .../Xserver/hw/xfree86/common/xf86xvpriv.h | 86 + nx-X11/programs/Xserver/hw/xfree86/common/xisb.c | 180 + nx-X11/programs/Xserver/hw/xfree86/common/xisb.h | 64 + .../Xserver/hw/xfree86/common/xorgHelper.c | 24 + .../Xserver/hw/xfree86/os-support/Imakefile | 130 + .../Xserver/hw/xfree86/os-support/README.OS-lib | 506 ++ .../Xserver/hw/xfree86/os-support/assyntax.h | 753 +++ .../Xserver/hw/xfree86/os-support/bsd/Imakefile | 242 + .../hw/xfree86/os-support/bsd/alpha_video.c | 735 +++ .../Xserver/hw/xfree86/os-support/bsd/arm_video.c | 690 +++ .../hw/xfree86/os-support/bsd/bsdResource.c | 194 + .../Xserver/hw/xfree86/os-support/bsd/bsd_KbdMap.c | 1087 ++++ .../Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c | 96 + .../Xserver/hw/xfree86/os-support/bsd/bsd_apm.c | 141 + .../Xserver/hw/xfree86/os-support/bsd/bsd_axp.c | 73 + .../Xserver/hw/xfree86/os-support/bsd/bsd_ev56.c | 91 + .../Xserver/hw/xfree86/os-support/bsd/bsd_init.c | 738 +++ .../Xserver/hw/xfree86/os-support/bsd/bsd_io.c | 294 + .../Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c | 189 + .../Xserver/hw/xfree86/os-support/bsd/bsd_kbd.c | 573 ++ .../Xserver/hw/xfree86/os-support/bsd/bsd_kbd.h | 5 + .../Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c | 31 + .../hw/xfree86/os-support/bsd/bsd_kqueue_apm.c | 203 + .../Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c | 792 +++ .../hw/xfree86/os-support/bsd/drm/Imakefile | 63 + .../Xserver/hw/xfree86/os-support/bsd/i386_video.c | 999 ++++ .../hw/xfree86/os-support/bsd/libusb/Imakefile | 10 + .../hw/xfree86/os-support/bsd/libusb/data.c | 95 + .../hw/xfree86/os-support/bsd/libusb/descr.c | 76 + .../hw/xfree86/os-support/bsd/libusb/parse.c | 404 ++ .../hw/xfree86/os-support/bsd/libusb/usage.c | 199 + .../Xserver/hw/xfree86/os-support/bsd/libusb/usb.3 | 191 + .../Xserver/hw/xfree86/os-support/bsd/libusb/usb.h | 95 + .../xfree86/os-support/bsd/libusb/usb_hid_usages | 1079 ++++ .../hw/xfree86/os-support/bsd/libusb/usbvar.h | 34 + .../Xserver/hw/xfree86/os-support/bsd/memrange.h | 72 + .../Xserver/hw/xfree86/os-support/bsd/ppc_video.c | 141 + .../hw/xfree86/os-support/bsd/sparc64_video.c | 113 + .../Xserver/hw/xfree86/os-support/bsdi/Imakefile | 46 + .../Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c | 156 + .../Xserver/hw/xfree86/os-support/bsdi/bsdi_io.c | 110 + .../hw/xfree86/os-support/bsdi/bsdi_mouse.c | 34 + .../hw/xfree86/os-support/bsdi/bsdi_video.c | 182 + .../Xserver/hw/xfree86/os-support/bus/460gxPCI.c | 470 ++ .../Xserver/hw/xfree86/os-support/bus/460gxPCI.h | 42 + .../Xserver/hw/xfree86/os-support/bus/Imakefile | 165 + .../Xserver/hw/xfree86/os-support/bus/Pci.c | 1453 +++++ .../Xserver/hw/xfree86/os-support/bus/Pci.h | 449 ++ .../Xserver/hw/xfree86/os-support/bus/Sbus.c | 637 ++ .../Xserver/hw/xfree86/os-support/bus/altixPCI.c | 120 + .../Xserver/hw/xfree86/os-support/bus/altixPCI.h | 20 + .../Xserver/hw/xfree86/os-support/bus/axpPci.c | 478 ++ .../Xserver/hw/xfree86/os-support/bus/e8870PCI.c | 64 + .../Xserver/hw/xfree86/os-support/bus/e8870PCI.h | 42 + .../Xserver/hw/xfree86/os-support/bus/freebsdPci.c | 171 + .../Xserver/hw/xfree86/os-support/bus/ix86Pci.c | 704 +++ .../Xserver/hw/xfree86/os-support/bus/linuxPci.c | 894 +++ .../Xserver/hw/xfree86/os-support/bus/netbsdPci.c | 132 + .../Xserver/hw/xfree86/os-support/bus/ppcPci.c | 311 + .../Xserver/hw/xfree86/os-support/bus/sparcPci.c | 1052 ++++ .../Xserver/hw/xfree86/os-support/bus/xf86Pci.h | 807 +++ .../Xserver/hw/xfree86/os-support/bus/xf86Sbus.h | 70 + .../Xserver/hw/xfree86/os-support/bus/zx1PCI.c | 1133 ++++ .../Xserver/hw/xfree86/os-support/bus/zx1PCI.h | 40 + .../Xserver/hw/xfree86/os-support/dgux/Imakefile | 35 + .../hw/xfree86/os-support/dgux/bios_DGmmap.c | 70 + .../Xserver/hw/xfree86/os-support/dgux/dgux_init.c | 182 + .../Xserver/hw/xfree86/os-support/dgux/dgux_io.c | 96 + .../Xserver/hw/xfree86/os-support/dgux/dgux_kbd.c | 120 + .../hw/xfree86/os-support/dgux/dgux_kbdEv.c | 47 + .../Xserver/hw/xfree86/os-support/dgux/dgux_tty.c | 175 + .../hw/xfree86/os-support/dgux/dgux_video.c | 441 ++ .../Xserver/hw/xfree86/os-support/hurd/Imakefile | 40 + .../Xserver/hw/xfree86/os-support/hurd/bios_mmap.c | 95 + .../Xserver/hw/xfree86/os-support/hurd/hurd_init.c | 90 + .../Xserver/hw/xfree86/os-support/hurd/hurd_io.c | 139 + .../hw/xfree86/os-support/hurd/hurd_mouse.c | 300 + .../hw/xfree86/os-support/hurd/hurd_video.c | 181 + .../Xserver/hw/xfree86/os-support/int10Defines.h | 90 + .../Xserver/hw/xfree86/os-support/linux/Imakefile | 142 + .../hw/xfree86/os-support/linux/drm/Imakefile | 64 + .../hw/xfree86/os-support/linux/drm/drmmodule.c | 60 + .../hw/xfree86/os-support/linux/int10/Imakefile | 77 + .../hw/xfree86/os-support/linux/int10/linux.c | 649 ++ .../xfree86/os-support/linux/int10/vm86/Imakefile | 55 + .../os-support/linux/int10/vm86/linux_vm86.c | 302 + .../os-support/linux/int10/x86emu/Imakefile | 86 + .../Xserver/hw/xfree86/os-support/linux/lnx.h | 55 + .../hw/xfree86/os-support/linux/lnxResource.c | 291 + .../hw/xfree86/os-support/linux/lnx_KbdMap.c | 606 ++ .../Xserver/hw/xfree86/os-support/linux/lnx_acpi.c | 170 + .../Xserver/hw/xfree86/os-support/linux/lnx_agp.c | 371 ++ .../Xserver/hw/xfree86/os-support/linux/lnx_apm.c | 192 + .../Xserver/hw/xfree86/os-support/linux/lnx_axp.c | 200 + .../Xserver/hw/xfree86/os-support/linux/lnx_ev56.c | 151 + .../Xserver/hw/xfree86/os-support/linux/lnx_font.c | 291 + .../Xserver/hw/xfree86/os-support/linux/lnx_ia64.c | 74 + .../Xserver/hw/xfree86/os-support/linux/lnx_init.c | 415 ++ .../Xserver/hw/xfree86/os-support/linux/lnx_io.c | 275 + .../Xserver/hw/xfree86/os-support/linux/lnx_jstk.c | 188 + .../Xserver/hw/xfree86/os-support/linux/lnx_kbd.c | 559 ++ .../Xserver/hw/xfree86/os-support/linux/lnx_kbd.h | 5 + .../Xserver/hw/xfree86/os-support/linux/lnx_kmod.c | 113 + .../hw/xfree86/os-support/linux/lnx_mouse.c | 206 + .../Xserver/hw/xfree86/os-support/linux/lnx_pci.c | 230 + .../hw/xfree86/os-support/linux/lnx_video.c | 1169 ++++ .../Xserver/hw/xfree86/os-support/lynxos/Imakefile | 62 + .../hw/xfree86/os-support/lynxos/lynx_init.c | 193 + .../Xserver/hw/xfree86/os-support/lynxos/lynx_io.c | 166 + .../hw/xfree86/os-support/lynxos/lynx_mmap.c | 73 + .../hw/xfree86/os-support/lynxos/lynx_mouse.c | 34 + .../hw/xfree86/os-support/lynxos/lynx_noinline.c | 178 + .../hw/xfree86/os-support/lynxos/lynx_ppc.S | 70 + .../hw/xfree86/os-support/lynxos/lynx_ppc.c | 52 + .../hw/xfree86/os-support/lynxos/lynx_video.c | 711 +++ .../Xserver/hw/xfree86/os-support/misc/BUSmemcpy.S | 153 + .../Xserver/hw/xfree86/os-support/misc/BUSmemcpy.c | 413 ++ .../Xserver/hw/xfree86/os-support/misc/Delay.c | 44 + .../Xserver/hw/xfree86/os-support/misc/IODelay.S | 53 + .../Xserver/hw/xfree86/os-support/misc/IODelay.c | 28 + .../Xserver/hw/xfree86/os-support/misc/Imakefile | 54 + .../Xserver/hw/xfree86/os-support/misc/PortIO.S | 57 + .../Xserver/hw/xfree86/os-support/misc/SlowBcopy.S | 108 + .../Xserver/hw/xfree86/os-support/misc/SlowBcopy.c | 114 + .../hw/xfree86/os-support/misc/xf86_IlHack.c | 19 + .../Xserver/hw/xfree86/os-support/misc/xf86_Util.c | 96 + .../Xserver/hw/xfree86/os-support/nto/Imakefile | 37 + .../Xserver/hw/xfree86/os-support/nto/README | 29 + .../Xserver/hw/xfree86/os-support/nto/nto_init.c | 104 + .../Xserver/hw/xfree86/os-support/nto/nto_io.c | 118 + .../Xserver/hw/xfree86/os-support/nto/nto_ioperm.c | 48 + .../Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c | 53 + .../Xserver/hw/xfree86/os-support/nto/nto_mouse.c | 210 + .../Xserver/hw/xfree86/os-support/nto/nto_video.c | 170 + .../Xserver/hw/xfree86/os-support/os2/Imakefile | 45 + .../Xserver/hw/xfree86/os-support/os2/README | 78 + .../hw/xfree86/os-support/os2/int10/Imakefile | 110 + .../Xserver/hw/xfree86/os-support/os2/int10/os2.c | 452 ++ .../Xserver/hw/xfree86/os-support/os2/os2_VTsw.c | 340 ++ .../Xserver/hw/xfree86/os-support/os2/os2_bios.c | 143 + .../Xserver/hw/xfree86/os-support/os2/os2_diag.c | 263 + .../Xserver/hw/xfree86/os-support/os2/os2_init.c | 244 + .../Xserver/hw/xfree86/os-support/os2/os2_io.c | 257 + .../Xserver/hw/xfree86/os-support/os2/os2_ioperm.c | 140 + .../Xserver/hw/xfree86/os-support/os2/os2_kbd.c | 158 + .../Xserver/hw/xfree86/os-support/os2/os2_kbdEv.c | 511 ++ .../Xserver/hw/xfree86/os-support/os2/os2_mouse.c | 653 ++ .../Xserver/hw/xfree86/os-support/os2/os2_select.c | 497 ++ .../Xserver/hw/xfree86/os-support/os2/os2_select.h | 62 + .../Xserver/hw/xfree86/os-support/os2/os2_serial.c | 517 ++ .../Xserver/hw/xfree86/os-support/os2/os2_stubs.c | 403 ++ .../Xserver/hw/xfree86/os-support/os2/os2_video.c | 241 + .../Xserver/hw/xfree86/os-support/pmax/Imakefile | 48 + .../Xserver/hw/xfree86/os-support/pmax/pmax_devs.c | 126 + .../Xserver/hw/xfree86/os-support/pmax/pmax_init.c | 473 ++ .../Xserver/hw/xfree86/os-support/pmax/pmax_map.c | 239 + .../hw/xfree86/os-support/pmax/pmax_mouse.c | 60 + .../Xserver/hw/xfree86/os-support/pmax/pmax_pci.c | 1072 ++++ .../Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c | 251 + .../Xserver/hw/xfree86/os-support/qnx4/Imakefile | 37 + .../Xserver/hw/xfree86/os-support/qnx4/qnx_VTsw.c | 116 + .../Xserver/hw/xfree86/os-support/qnx4/qnx_init.c | 175 + .../Xserver/hw/xfree86/os-support/qnx4/qnx_io.c | 110 + .../Xserver/hw/xfree86/os-support/qnx4/qnx_kbd.c | 104 + .../Xserver/hw/xfree86/os-support/qnx4/qnx_mouse.c | 267 + .../hw/xfree86/os-support/qnx4/qnx_select.c | 75 + .../Xserver/hw/xfree86/os-support/qnx4/qnx_utils.c | 30 + .../Xserver/hw/xfree86/os-support/qnx4/qnx_video.c | 183 + .../Xserver/hw/xfree86/os-support/sco/Imakefile | 56 + .../Xserver/hw/xfree86/os-support/sco/VTsw_sco.c | 119 + .../Xserver/hw/xfree86/os-support/sco/sco_KbdMap.c | 304 + .../Xserver/hw/xfree86/os-support/sco/sco_init.c | 296 + .../Xserver/hw/xfree86/os-support/sco/sco_io.c | 269 + .../Xserver/hw/xfree86/os-support/sco/sco_iop.c | 136 + .../Xserver/hw/xfree86/os-support/sco/sco_kbd.c | 530 ++ .../Xserver/hw/xfree86/os-support/sco/sco_kbd.h | 20 + .../Xserver/hw/xfree86/os-support/sco/sco_mouse.c | 261 + .../Xserver/hw/xfree86/os-support/sco/sco_video.c | 296 + .../hw/xfree86/os-support/shared/VTsw_noop.c | 56 + .../hw/xfree86/os-support/shared/VTsw_usl.c | 92 + .../hw/xfree86/os-support/shared/agp_noop.c | 107 + .../hw/xfree86/os-support/shared/at_scancode.c | 132 + .../hw/xfree86/os-support/shared/bios_devmem.c | 77 + .../hw/xfree86/os-support/shared/bios_mmap.c | 164 + .../Xserver/hw/xfree86/os-support/shared/ia64Pci.c | 244 + .../Xserver/hw/xfree86/os-support/shared/ia64Pci.h | 46 + .../Xserver/hw/xfree86/os-support/shared/inout.S | 111 + .../hw/xfree86/os-support/shared/ioperm_noop.c | 51 + .../Xserver/hw/xfree86/os-support/shared/kbd.c | 39 + .../hw/xfree86/os-support/shared/kmod_noop.c | 39 + .../hw/xfree86/os-support/shared/libc_wrapper.c | 2153 +++++++ .../Xserver/hw/xfree86/os-support/shared/pm_noop.c | 48 + .../hw/xfree86/os-support/shared/posix_tty.c | 689 +++ .../Xserver/hw/xfree86/os-support/shared/sigio.c | 312 + .../hw/xfree86/os-support/shared/sigiostubs.c | 86 + .../Xserver/hw/xfree86/os-support/shared/stdPci.c | 52 + .../hw/xfree86/os-support/shared/stdResource.c | 182 + .../hw/xfree86/os-support/shared/std_kbdEv.c | 50 + .../hw/xfree86/os-support/shared/sysv_kbd.c | 106 + .../Xserver/hw/xfree86/os-support/shared/vidmem.c | 300 + .../Xserver/hw/xfree86/os-support/shared/xf86Axp.c | 50 + .../Xserver/hw/xfree86/os-support/shared/xf86Axp.h | 36 + .../Xserver/hw/xfree86/os-support/sunos/Imakefile | 119 + .../Xserver/hw/xfree86/os-support/sunos/agpgart.h | 109 + .../hw/xfree86/os-support/sunos/find_deps.pl | 150 + .../hw/xfree86/os-support/sunos/solaris-amd64.S | 73 + .../hw/xfree86/os-support/sunos/solaris-ia32.S | 73 + .../xfree86/os-support/sunos/solaris-sparcv8plus.S | 144 + .../Xserver/hw/xfree86/os-support/sunos/sun_agp.c | 339 ++ .../Xserver/hw/xfree86/os-support/sunos/sun_bios.c | 104 + .../Xserver/hw/xfree86/os-support/sunos/sun_init.c | 393 ++ .../hw/xfree86/os-support/sunos/sun_inout.s | 124 + .../Xserver/hw/xfree86/os-support/sunos/sun_io.c | 160 + .../Xserver/hw/xfree86/os-support/sunos/sun_kbd.c | 662 +++ .../Xserver/hw/xfree86/os-support/sunos/sun_kbd.h | 72 + .../hw/xfree86/os-support/sunos/sun_kbdEv.c | 892 +++ .../hw/xfree86/os-support/sunos/sun_mouse.c | 719 +++ .../Xserver/hw/xfree86/os-support/sunos/sun_vid.c | 237 + .../Xserver/hw/xfree86/os-support/sysv/Imakefile | 58 + .../Xserver/hw/xfree86/os-support/sysv/sysv_init.c | 254 + .../Xserver/hw/xfree86/os-support/sysv/sysv_io.c | 78 + .../hw/xfree86/os-support/sysv/sysv_mouse.c | 64 + .../hw/xfree86/os-support/sysv/sysv_video.c | 369 ++ .../Xserver/hw/xfree86/os-support/sysv/xqueue.c | 543 ++ .../Xserver/hw/xfree86/os-support/sysv/xqueue.h | 12 + .../Xserver/hw/xfree86/os-support/usl/Imakefile | 40 + .../Xserver/hw/xfree86/os-support/usl/usl_KbdMap.c | 304 + .../Xserver/hw/xfree86/os-support/usl/usl_init.c | 359 ++ .../Xserver/hw/xfree86/os-support/usl/usl_io.c | 172 + .../Xserver/hw/xfree86/os-support/usl/usl_iop.c | 108 + .../Xserver/hw/xfree86/os-support/usl/usl_kbd.c | 456 ++ .../Xserver/hw/xfree86/os-support/usl/usl_kbd.h | 14 + .../Xserver/hw/xfree86/os-support/usl/usl_mouse.c | 181 + .../Xserver/hw/xfree86/os-support/usl/usl_video.c | 111 + .../Xserver/hw/xfree86/os-support/usl/usl_vtsw.c | 97 + .../Xserver/hw/xfree86/os-support/usl/usl_xqueue.c | 360 ++ .../Xserver/hw/xfree86/os-support/usl/usl_xqueue.h | 9 + .../Xserver/hw/xfree86/os-support/xf86OSKbd.h | 133 + .../Xserver/hw/xfree86/os-support/xf86OSmouse.h | 295 + .../Xserver/hw/xfree86/os-support/xf86OSpriv.h | 57 + .../Xserver/hw/xfree86/os-support/xf86_OSlib.h | 759 +++ .../Xserver/hw/xfree86/os-support/xf86_OSproc.h | 277 + .../Xserver/hw/xfree86/os-support/xf86_ansic.h | 354 ++ .../Xserver/hw/xfree86/os-support/xf86_libc.h | 726 +++ .../programs/Xserver/hw/xfree86/parser/Configint.h | 226 + nx-X11/programs/Xserver/hw/xfree86/parser/DRI.c | 187 + nx-X11/programs/Xserver/hw/xfree86/parser/Device.c | 403 ++ .../Xserver/hw/xfree86/parser/Extensions.c | 111 + nx-X11/programs/Xserver/hw/xfree86/parser/Files.c | 295 + nx-X11/programs/Xserver/hw/xfree86/parser/Flags.c | 525 ++ .../programs/Xserver/hw/xfree86/parser/Imakefile | 51 + nx-X11/programs/Xserver/hw/xfree86/parser/Input.c | 215 + .../programs/Xserver/hw/xfree86/parser/Keyboard.c | 306 + nx-X11/programs/Xserver/hw/xfree86/parser/Layout.c | 513 ++ nx-X11/programs/Xserver/hw/xfree86/parser/Module.c | 261 + .../programs/Xserver/hw/xfree86/parser/Monitor.c | 907 +++ .../programs/Xserver/hw/xfree86/parser/Pointer.c | 236 + nx-X11/programs/Xserver/hw/xfree86/parser/Screen.c | 578 ++ nx-X11/programs/Xserver/hw/xfree86/parser/Vendor.c | 258 + nx-X11/programs/Xserver/hw/xfree86/parser/Video.c | 297 + .../Xserver/hw/xfree86/parser/configProcs.h | 132 + .../programs/Xserver/hw/xfree86/parser/cpconfig.c | 123 + nx-X11/programs/Xserver/hw/xfree86/parser/read.c | 321 + nx-X11/programs/Xserver/hw/xfree86/parser/scan.c | 949 +++ nx-X11/programs/Xserver/hw/xfree86/parser/write.c | 220 + .../Xserver/hw/xfree86/parser/xf86Optrec.h | 113 + .../Xserver/hw/xfree86/parser/xf86Parser.h | 483 ++ .../Xserver/hw/xfree86/parser/xf86tokens.h | 280 + nx-X11/programs/Xserver/hw/xfree86/xf86Date.h | 38 + nx-X11/programs/Xserver/hw/xfree86/xf86Version.h | 62 + nx-X11/programs/Xserver/hw/xnest/Args.c | 197 + nx-X11/programs/Xserver/hw/xnest/Args.h | 40 + nx-X11/programs/Xserver/hw/xnest/Color.c | 497 ++ nx-X11/programs/Xserver/hw/xnest/Color.h | 58 + nx-X11/programs/Xserver/hw/xnest/Cursor.c | 159 + nx-X11/programs/Xserver/hw/xnest/Display.c | 195 + nx-X11/programs/Xserver/hw/xnest/Display.h | 46 + nx-X11/programs/Xserver/hw/xnest/Drawable.h | 28 + nx-X11/programs/Xserver/hw/xnest/Events.c | 226 + nx-X11/programs/Xserver/hw/xnest/Events.h | 31 + nx-X11/programs/Xserver/hw/xnest/Font.c | 91 + nx-X11/programs/Xserver/hw/xnest/GC.c | 340 ++ nx-X11/programs/Xserver/hw/xnest/GCOps.c | 329 ++ nx-X11/programs/Xserver/hw/xnest/GCOps.h | 70 + nx-X11/programs/Xserver/hw/xnest/GetTime.c | 51 + nx-X11/programs/Xserver/hw/xnest/Handlers.c | 47 + nx-X11/programs/Xserver/hw/xnest/Handlers.h | 24 + nx-X11/programs/Xserver/hw/xnest/Imakefile | 90 + nx-X11/programs/Xserver/hw/xnest/Init.c | 164 + nx-X11/programs/Xserver/hw/xnest/Init.h | 21 + nx-X11/programs/Xserver/hw/xnest/Keyboard.c | 339 ++ nx-X11/programs/Xserver/hw/xnest/Keyboard.h | 30 + nx-X11/programs/Xserver/hw/xnest/Pixmap.c | 141 + nx-X11/programs/Xserver/hw/xnest/Pointer.c | 79 + nx-X11/programs/Xserver/hw/xnest/Pointer.h | 31 + nx-X11/programs/Xserver/hw/xnest/Screen.c | 458 ++ nx-X11/programs/Xserver/hw/xnest/Screen.h | 27 + nx-X11/programs/Xserver/hw/xnest/TestExt.c | 69 + nx-X11/programs/Xserver/hw/xnest/Visual.c | 72 + nx-X11/programs/Xserver/hw/xnest/Visual.h | 27 + nx-X11/programs/Xserver/hw/xnest/Window.c | 558 ++ nx-X11/programs/Xserver/hw/xnest/XNCursor.h | 35 + nx-X11/programs/Xserver/hw/xnest/XNFont.h | 37 + nx-X11/programs/Xserver/hw/xnest/XNGC.h | 44 + nx-X11/programs/Xserver/hw/xnest/XNPixmap.h | 45 + nx-X11/programs/Xserver/hw/xnest/XNWindow.h | 80 + nx-X11/programs/Xserver/hw/xnest/Xnest.h | 96 + nx-X11/programs/Xserver/hw/xnest/Xnest.man | 264 + nx-X11/programs/Xserver/hw/xnest/icon | 14 + nx-X11/programs/Xserver/hw/xnest/os2Stub.c | 388 ++ nx-X11/programs/Xserver/hw/xnest/screensaver | 686 +++ nx-X11/programs/Xserver/hw/xwin/ChangeLog | 663 +++ nx-X11/programs/Xserver/hw/xwin/Imakefile | 310 + nx-X11/programs/Xserver/hw/xwin/InitInput.c | 204 + nx-X11/programs/Xserver/hw/xwin/InitOutput.c | 1172 ++++ nx-X11/programs/Xserver/hw/xwin/README | 141 + nx-X11/programs/Xserver/hw/xwin/X-boxed.ico | Bin 0 -> 12902 bytes nx-X11/programs/Xserver/hw/xwin/X.ico | Bin 0 -> 20870 bytes nx-X11/programs/Xserver/hw/xwin/XWin.man | 287 + nx-X11/programs/Xserver/hw/xwin/XWin.rc | 110 + nx-X11/programs/Xserver/hw/xwin/XWinrc.man | 180 + .../hw/xwin/_usr_X11R6_lib_X11_system.XWinrc | 125 + nx-X11/programs/Xserver/hw/xwin/ddraw.h | 2108 +++++++ nx-X11/programs/Xserver/hw/xwin/win.h | 1466 +++++ nx-X11/programs/Xserver/hw/xwin/winallpriv.c | 185 + nx-X11/programs/Xserver/hw/xwin/winauth.c | 132 + nx-X11/programs/Xserver/hw/xwin/winblock.c | 106 + nx-X11/programs/Xserver/hw/xwin/winclip.c | 42 + nx-X11/programs/Xserver/hw/xwin/winclipboard.h | 164 + nx-X11/programs/Xserver/hw/xwin/winclipboardinit.c | 143 + .../Xserver/hw/xwin/winclipboardtextconv.c | 159 + .../programs/Xserver/hw/xwin/winclipboardthread.c | 477 ++ .../programs/Xserver/hw/xwin/winclipboardunicode.c | 69 + .../programs/Xserver/hw/xwin/winclipboardwndproc.c | 585 ++ .../Xserver/hw/xwin/winclipboardwrappers.c | 544 ++ .../programs/Xserver/hw/xwin/winclipboardxevents.c | 796 +++ nx-X11/programs/Xserver/hw/xwin/wincmap.c | 675 +++ nx-X11/programs/Xserver/hw/xwin/winconfig.c | 1185 ++++ nx-X11/programs/Xserver/hw/xwin/winconfig.h | 345 ++ nx-X11/programs/Xserver/hw/xwin/wincreatewnd.c | 642 ++ nx-X11/programs/Xserver/hw/xwin/wincursor.c | 615 ++ nx-X11/programs/Xserver/hw/xwin/windialogs.c | 788 +++ nx-X11/programs/Xserver/hw/xwin/winengine.c | 336 ++ nx-X11/programs/Xserver/hw/xwin/winerror.c | 143 + nx-X11/programs/Xserver/hw/xwin/winfillsp.c | 876 +++ nx-X11/programs/Xserver/hw/xwin/winfont.c | 80 + nx-X11/programs/Xserver/hw/xwin/wingc.c | 259 + nx-X11/programs/Xserver/hw/xwin/wingetsp.c | 193 + nx-X11/programs/Xserver/hw/xwin/winglobals.c | 138 + nx-X11/programs/Xserver/hw/xwin/winkeybd.c | 650 ++ nx-X11/programs/Xserver/hw/xwin/winkeybd.h | 310 + nx-X11/programs/Xserver/hw/xwin/winkeyhook.c | 194 + nx-X11/programs/Xserver/hw/xwin/winkeymap.h | 138 + nx-X11/programs/Xserver/hw/xwin/winkeynames.h | 204 + nx-X11/programs/Xserver/hw/xwin/winlayouts.h | 257 + nx-X11/programs/Xserver/hw/xwin/winmessages.h | 1030 ++++ nx-X11/programs/Xserver/hw/xwin/winmisc.c | 152 + nx-X11/programs/Xserver/hw/xwin/winmouse.c | 341 ++ nx-X11/programs/Xserver/hw/xwin/winms.h | 46 + nx-X11/programs/Xserver/hw/xwin/winmsg.c | 180 + nx-X11/programs/Xserver/hw/xwin/winmsg.h | 52 + .../programs/Xserver/hw/xwin/winmultiwindowclass.c | 326 + .../programs/Xserver/hw/xwin/winmultiwindowclass.h | 116 + .../programs/Xserver/hw/xwin/winmultiwindowicons.c | 478 ++ .../programs/Xserver/hw/xwin/winmultiwindowshape.c | 212 + .../Xserver/hw/xwin/winmultiwindowwindow.c | 1056 ++++ nx-X11/programs/Xserver/hw/xwin/winmultiwindowwm.c | 1444 +++++ .../Xserver/hw/xwin/winmultiwindowwndproc.c | 1035 ++++ nx-X11/programs/Xserver/hw/xwin/winnativegdi.c | 547 ++ nx-X11/programs/Xserver/hw/xwin/winpfbdd.c | 685 +++ nx-X11/programs/Xserver/hw/xwin/winpixmap.c | 242 + nx-X11/programs/Xserver/hw/xwin/winpntwin.c | 47 + nx-X11/programs/Xserver/hw/xwin/winpolyline.c | 57 + nx-X11/programs/Xserver/hw/xwin/winprefs.c | 799 +++ nx-X11/programs/Xserver/hw/xwin/winprefs.h | 163 + nx-X11/programs/Xserver/hw/xwin/winprefslex.l | 116 + nx-X11/programs/Xserver/hw/xwin/winprefsyacc.y | 353 ++ nx-X11/programs/Xserver/hw/xwin/winpriv.c | 134 + nx-X11/programs/Xserver/hw/xwin/winpriv.h | 15 + nx-X11/programs/Xserver/hw/xwin/winprocarg.c | 1561 +++++ nx-X11/programs/Xserver/hw/xwin/winpushpxl.c | 226 + nx-X11/programs/Xserver/hw/xwin/winrandr.c | 141 + nx-X11/programs/Xserver/hw/xwin/winregistry.c | 71 + nx-X11/programs/Xserver/hw/xwin/winresource.h | 56 + nx-X11/programs/Xserver/hw/xwin/winrop.c | 145 + nx-X11/programs/Xserver/hw/xwin/winscrinit.c | 794 +++ nx-X11/programs/Xserver/hw/xwin/winsetsp.c | 196 + nx-X11/programs/Xserver/hw/xwin/winshaddd.c | 1443 +++++ nx-X11/programs/Xserver/hw/xwin/winshadddnl.c | 1455 +++++ nx-X11/programs/Xserver/hw/xwin/winshadgdi.c | 1323 +++++ nx-X11/programs/Xserver/hw/xwin/wintrayicon.c | 211 + nx-X11/programs/Xserver/hw/xwin/winvalargs.c | 188 + nx-X11/programs/Xserver/hw/xwin/winvideo.c | 210 + nx-X11/programs/Xserver/hw/xwin/winwakeup.c | 72 + nx-X11/programs/Xserver/hw/xwin/winwin32rootless.c | 1092 ++++ .../Xserver/hw/xwin/winwin32rootlesswindow.c | 476 ++ .../Xserver/hw/xwin/winwin32rootlesswndproc.c | 1324 +++++ nx-X11/programs/Xserver/hw/xwin/winwindow.c | 650 ++ nx-X11/programs/Xserver/hw/xwin/winwindow.h | 151 + nx-X11/programs/Xserver/hw/xwin/winwindowswm.c | 666 +++ nx-X11/programs/Xserver/hw/xwin/winwndproc.c | 1273 ++++ nx-X11/programs/Xserver/hw/xwin/xlaunch/COPYING | 25 + nx-X11/programs/Xserver/hw/xwin/xlaunch/Makefile | 79 + nx-X11/programs/Xserver/hw/xwin/xlaunch/config.cc | 282 + nx-X11/programs/Xserver/hw/xwin/xlaunch/config.h | 60 + nx-X11/programs/Xserver/hw/xwin/xlaunch/main.cc | 700 +++ .../Xserver/hw/xwin/xlaunch/resources/dialog.rc | 118 + .../hw/xwin/xlaunch/resources/fullscreen.bmp | Bin 0 -> 22554 bytes .../Xserver/hw/xwin/xlaunch/resources/images.rc | 29 + .../hw/xwin/xlaunch/resources/multiwindow.bmp | Bin 0 -> 22554 bytes .../hw/xwin/xlaunch/resources/nodecoration.bmp | Bin 0 -> 22554 bytes .../Xserver/hw/xwin/xlaunch/resources/resources.h | 99 + .../Xserver/hw/xwin/xlaunch/resources/resources.rc | 30 + .../Xserver/hw/xwin/xlaunch/resources/strings.rc | 108 + .../Xserver/hw/xwin/xlaunch/resources/windowed.bmp | Bin 0 -> 22554 bytes .../Xserver/hw/xwin/xlaunch/window/dialog.cc | 86 + .../Xserver/hw/xwin/xlaunch/window/dialog.h | 54 + .../Xserver/hw/xwin/xlaunch/window/util.cc | 1112 ++++ .../programs/Xserver/hw/xwin/xlaunch/window/util.h | 53 + .../Xserver/hw/xwin/xlaunch/window/window.cc | 284 + .../Xserver/hw/xwin/xlaunch/window/window.h | 114 + .../Xserver/hw/xwin/xlaunch/window/wizard.cc | 244 + .../Xserver/hw/xwin/xlaunch/window/wizard.h | 59 + nx-X11/programs/Xserver/ilbm/Imakefile | 63 + nx-X11/programs/Xserver/ilbm/README | 17 + nx-X11/programs/Xserver/ilbm/ilbm.h | 1051 ++++ nx-X11/programs/Xserver/ilbm/ilbmbitblt.c | 483 ++ nx-X11/programs/Xserver/ilbm/ilbmblt.c | 573 ++ nx-X11/programs/Xserver/ilbm/ilbmbres.c | 328 + nx-X11/programs/Xserver/ilbm/ilbmbresd.c | 219 + nx-X11/programs/Xserver/ilbm/ilbmbstore.c | 159 + nx-X11/programs/Xserver/ilbm/ilbmclip.c | 246 + nx-X11/programs/Xserver/ilbm/ilbmcmap.c | 128 + nx-X11/programs/Xserver/ilbm/ilbmfillarc.c | 377 ++ nx-X11/programs/Xserver/ilbm/ilbmfillrct.c | 299 + nx-X11/programs/Xserver/ilbm/ilbmfillsp.c | 1149 ++++ nx-X11/programs/Xserver/ilbm/ilbmfont.c | 82 + nx-X11/programs/Xserver/ilbm/ilbmgc.c | 715 +++ nx-X11/programs/Xserver/ilbm/ilbmgetsp.c | 170 + nx-X11/programs/Xserver/ilbm/ilbmhrzvert.c | 213 + nx-X11/programs/Xserver/ilbm/ilbmimage.c | 441 ++ nx-X11/programs/Xserver/ilbm/ilbmimggblt.c | 474 ++ nx-X11/programs/Xserver/ilbm/ilbmline.c | 705 +++ nx-X11/programs/Xserver/ilbm/ilbmmisc.c | 99 + nx-X11/programs/Xserver/ilbm/ilbmpixmap.c | 295 + nx-X11/programs/Xserver/ilbm/ilbmply1rct.c | 303 + nx-X11/programs/Xserver/ilbm/ilbmplygblt.c | 469 ++ nx-X11/programs/Xserver/ilbm/ilbmpntarea.c | 656 ++ nx-X11/programs/Xserver/ilbm/ilbmpntwin.c | 131 + nx-X11/programs/Xserver/ilbm/ilbmpolypnt.c | 152 + nx-X11/programs/Xserver/ilbm/ilbmpushpxl.c | 263 + nx-X11/programs/Xserver/ilbm/ilbmscrinit.c | 251 + nx-X11/programs/Xserver/ilbm/ilbmsetsp.c | 269 + nx-X11/programs/Xserver/ilbm/ilbmtegblt.c | 599 ++ nx-X11/programs/Xserver/ilbm/ilbmtile.c | 857 +++ nx-X11/programs/Xserver/ilbm/ilbmwindow.c | 323 + nx-X11/programs/Xserver/ilbm/ilbmzerarc.c | 214 + nx-X11/programs/Xserver/include/Imakefile | 67 + nx-X11/programs/Xserver/include/XIstubs.h | 76 + nx-X11/programs/Xserver/include/bstore.h | 23 + nx-X11/programs/Xserver/include/bstorestr.h | 58 + nx-X11/programs/Xserver/include/closestr.h | 159 + nx-X11/programs/Xserver/include/closure.h | 58 + nx-X11/programs/Xserver/include/colormap.h | 184 + nx-X11/programs/Xserver/include/colormapst.h | 121 + nx-X11/programs/Xserver/include/cursor.h | 149 + nx-X11/programs/Xserver/include/cursorstr.h | 98 + nx-X11/programs/Xserver/include/dix.h | 817 +++ nx-X11/programs/Xserver/include/dixevents.h | 106 + nx-X11/programs/Xserver/include/dixfont.h | 155 + nx-X11/programs/Xserver/include/dixfontstr.h | 95 + nx-X11/programs/Xserver/include/dixgrabs.h | 59 + nx-X11/programs/Xserver/include/dixstruct.h | 236 + .../Xserver/include/dixstruct.h.NX.original | 236 + .../Xserver/include/dixstruct.h.X.original | 233 + nx-X11/programs/Xserver/include/exevents.h | 183 + nx-X11/programs/Xserver/include/extension.h | 67 + nx-X11/programs/Xserver/include/extinit.h | 166 + nx-X11/programs/Xserver/include/extnsionst.h | 152 + nx-X11/programs/Xserver/include/gc.h | 178 + nx-X11/programs/Xserver/include/gcstruct.h | 328 + nx-X11/programs/Xserver/include/globals.h | 192 + nx-X11/programs/Xserver/include/input.h | 391 ++ nx-X11/programs/Xserver/include/inputstr.h | 314 + nx-X11/programs/Xserver/include/misc.h | 269 + nx-X11/programs/Xserver/include/miscstruct.h | 80 + nx-X11/programs/Xserver/include/opaque.h | 83 + nx-X11/programs/Xserver/include/os.h | 546 ++ nx-X11/programs/Xserver/include/pixmap.h | 110 + nx-X11/programs/Xserver/include/pixmapstr.h | 88 + nx-X11/programs/Xserver/include/property.h | 74 + nx-X11/programs/Xserver/include/propertyst.h | 76 + nx-X11/programs/Xserver/include/region.h | 54 + nx-X11/programs/Xserver/include/regionstr.h | 412 ++ nx-X11/programs/Xserver/include/resource.h | 274 + nx-X11/programs/Xserver/include/rgb.h | 54 + nx-X11/programs/Xserver/include/screenint.h | 113 + nx-X11/programs/Xserver/include/scrnintstr.h | 733 +++ nx-X11/programs/Xserver/include/selection.h | 69 + nx-X11/programs/Xserver/include/servermd.h | 583 ++ nx-X11/programs/Xserver/include/site.h | 139 + nx-X11/programs/Xserver/include/swaprep.h | 322 + nx-X11/programs/Xserver/include/swapreq.h | 120 + nx-X11/programs/Xserver/include/validate.h | 42 + nx-X11/programs/Xserver/include/window.h | 265 + nx-X11/programs/Xserver/include/windowstr.h | 234 + nx-X11/programs/Xserver/iplan2p2/Imakefile | 6 + nx-X11/programs/Xserver/iplan2p4/Imakefile | 119 + nx-X11/programs/Xserver/iplan2p4/ipl.h | 1254 ++++ nx-X11/programs/Xserver/iplan2p4/iplallpriv.c | 93 + nx-X11/programs/Xserver/iplan2p4/iplbitblt.c | 388 ++ nx-X11/programs/Xserver/iplan2p4/iplblt.c | 431 ++ nx-X11/programs/Xserver/iplan2p4/iplbres.c | 186 + nx-X11/programs/Xserver/iplan2p4/iplbresd.c | 212 + nx-X11/programs/Xserver/iplan2p4/iplbstore.c | 159 + nx-X11/programs/Xserver/iplan2p4/iplcmap.c | 126 + nx-X11/programs/Xserver/iplan2p4/iplfillarc.c | 271 + nx-X11/programs/Xserver/iplan2p4/iplfillrct.c | 281 + nx-X11/programs/Xserver/iplan2p4/iplfillsp.c | 384 ++ nx-X11/programs/Xserver/iplan2p4/iplgc.c | 786 +++ nx-X11/programs/Xserver/iplan2p4/iplgetsp.c | 166 + nx-X11/programs/Xserver/iplan2p4/iplhrzvert.c | 128 + nx-X11/programs/Xserver/iplan2p4/iplimage.c | 87 + nx-X11/programs/Xserver/iplan2p4/iplline.c | 758 +++ nx-X11/programs/Xserver/iplan2p4/iplmap.h | 176 + nx-X11/programs/Xserver/iplan2p4/iplmergerop.h | 146 + nx-X11/programs/Xserver/iplan2p4/iplmskbits.c | 108 + nx-X11/programs/Xserver/iplan2p4/iplmskbits.h | 500 ++ nx-X11/programs/Xserver/iplan2p4/iplpack.c | 316 + nx-X11/programs/Xserver/iplan2p4/iplpack.h | 10 + nx-X11/programs/Xserver/iplan2p4/iplpixmap.c | 386 ++ nx-X11/programs/Xserver/iplan2p4/iplply1rct.c | 310 + nx-X11/programs/Xserver/iplan2p4/iplpntwin.c | 341 ++ nx-X11/programs/Xserver/iplan2p4/iplpolypnt.c | 123 + nx-X11/programs/Xserver/iplan2p4/iplrrop.c | 219 + nx-X11/programs/Xserver/iplan2p4/iplrrop.h | 80 + nx-X11/programs/Xserver/iplan2p4/iplscrinit.c | 233 + nx-X11/programs/Xserver/iplan2p4/iplsetsp.c | 304 + nx-X11/programs/Xserver/iplan2p4/iplsolid.c | 221 + nx-X11/programs/Xserver/iplan2p4/ipltegblt.c | 221 + nx-X11/programs/Xserver/iplan2p4/ipltile32.c | 272 + nx-X11/programs/Xserver/iplan2p4/ipltileodd.c | 869 +++ nx-X11/programs/Xserver/iplan2p4/iplwindow.c | 343 ++ nx-X11/programs/Xserver/iplan2p8/Imakefile | 6 + nx-X11/programs/Xserver/lbx/Imakefile | 56 + nx-X11/programs/Xserver/lbx/lbxcmap.c | 1156 ++++ nx-X11/programs/Xserver/lbx/lbxdata.h | 48 + nx-X11/programs/Xserver/lbx/lbxdix.c | 869 +++ nx-X11/programs/Xserver/lbx/lbxexts.c | 275 + nx-X11/programs/Xserver/lbx/lbxgfx.c | 854 +++ nx-X11/programs/Xserver/lbx/lbxmain.c | 1760 ++++++ nx-X11/programs/Xserver/lbx/lbxopts.c | 806 +++ nx-X11/programs/Xserver/lbx/lbxprop.c | 549 ++ nx-X11/programs/Xserver/lbx/lbxserve.h | 289 + nx-X11/programs/Xserver/lbx/lbxsquish.c | 158 + nx-X11/programs/Xserver/lbx/lbxsrvopts.h | 67 + nx-X11/programs/Xserver/lbx/lbxswap.c | 828 +++ nx-X11/programs/Xserver/lbx/lbxtables.c | 39 + nx-X11/programs/Xserver/lbx/lbxtags.c | 237 + nx-X11/programs/Xserver/lbx/lbxtags.h | 86 + nx-X11/programs/Xserver/lbx/lbxzerorep.c | 420 ++ nx-X11/programs/Xserver/mfb/Imakefile | 168 + nx-X11/programs/Xserver/mfb/fastblt.h | 98 + nx-X11/programs/Xserver/mfb/maskbits.c | 1061 ++++ nx-X11/programs/Xserver/mfb/maskbits.h | 691 +++ nx-X11/programs/Xserver/mfb/mergerop.h | 400 ++ nx-X11/programs/Xserver/mfb/mfb.h | 1158 ++++ nx-X11/programs/Xserver/mfb/mfbbitblt.c | 510 ++ nx-X11/programs/Xserver/mfb/mfbblt.c | 589 ++ nx-X11/programs/Xserver/mfb/mfbbres.c | 370 ++ nx-X11/programs/Xserver/mfb/mfbbresd.c | 209 + nx-X11/programs/Xserver/mfb/mfbbstore.c | 155 + nx-X11/programs/Xserver/mfb/mfbclip.c | 280 + nx-X11/programs/Xserver/mfb/mfbcmap.c | 164 + nx-X11/programs/Xserver/mfb/mfbfillarc.c | 333 ++ nx-X11/programs/Xserver/mfb/mfbfillrct.c | 228 + nx-X11/programs/Xserver/mfb/mfbfillsp.c | 1028 ++++ nx-X11/programs/Xserver/mfb/mfbfont.c | 88 + nx-X11/programs/Xserver/mfb/mfbgc.c | 1151 ++++ nx-X11/programs/Xserver/mfb/mfbgetsp.c | 159 + nx-X11/programs/Xserver/mfb/mfbhrzvert.c | 179 + nx-X11/programs/Xserver/mfb/mfbimage.c | 177 + nx-X11/programs/Xserver/mfb/mfbimggblt.c | 445 ++ nx-X11/programs/Xserver/mfb/mfbline.c | 757 +++ nx-X11/programs/Xserver/mfb/mfbmisc.c | 100 + nx-X11/programs/Xserver/mfb/mfbmodule.c | 52 + nx-X11/programs/Xserver/mfb/mfbpixmap.c | 298 + nx-X11/programs/Xserver/mfb/mfbply1rct.c | 261 + nx-X11/programs/Xserver/mfb/mfbplygblt.c | 399 ++ nx-X11/programs/Xserver/mfb/mfbpntarea.c | 300 + nx-X11/programs/Xserver/mfb/mfbpntwin.c | 127 + nx-X11/programs/Xserver/mfb/mfbpolypnt.c | 145 + nx-X11/programs/Xserver/mfb/mfbpushpxl.c | 287 + nx-X11/programs/Xserver/mfb/mfbscrclse.c | 66 + nx-X11/programs/Xserver/mfb/mfbscrinit.c | 210 + nx-X11/programs/Xserver/mfb/mfbsetsp.c | 283 + nx-X11/programs/Xserver/mfb/mfbtegblt.c | 368 ++ nx-X11/programs/Xserver/mfb/mfbtile.c | 240 + nx-X11/programs/Xserver/mfb/mfbwindow.c | 341 ++ nx-X11/programs/Xserver/mfb/mfbzerarc.c | 258 + nx-X11/programs/Xserver/mfb/module/Imakefile | 6 + nx-X11/programs/Xserver/mi/Imakefile | 128 + nx-X11/programs/Xserver/mi/Imakefile.NX.original | 128 + nx-X11/programs/Xserver/mi/Imakefile.X.original | 94 + nx-X11/programs/Xserver/mi/cbrt.c | 48 + nx-X11/programs/Xserver/mi/mi.h | 645 ++ nx-X11/programs/Xserver/mi/miarc.c | 3723 ++++++++++++ nx-X11/programs/Xserver/mi/mibank.c | 2577 ++++++++ nx-X11/programs/Xserver/mi/mibank.h | 119 + nx-X11/programs/Xserver/mi/mibitblt.c | 845 +++ nx-X11/programs/Xserver/mi/mibstore.c | 3905 ++++++++++++ nx-X11/programs/Xserver/mi/mibstore.h | 30 + nx-X11/programs/Xserver/mi/mibstorest.h | 93 + nx-X11/programs/Xserver/mi/miclipn.c | 84 + nx-X11/programs/Xserver/mi/micmap.c | 697 +++ nx-X11/programs/Xserver/mi/micmap.h | 65 + nx-X11/programs/Xserver/mi/micoord.h | 71 + nx-X11/programs/Xserver/mi/micursor.c | 77 + nx-X11/programs/Xserver/mi/midash.c | 315 + nx-X11/programs/Xserver/mi/midispcur.c | 816 +++ nx-X11/programs/Xserver/mi/mieq.c | 192 + nx-X11/programs/Xserver/mi/miexpose.c | 905 +++ nx-X11/programs/Xserver/mi/mifillarc.c | 817 +++ nx-X11/programs/Xserver/mi/mifillarc.h | 216 + nx-X11/programs/Xserver/mi/mifillrct.c | 144 + nx-X11/programs/Xserver/mi/mifpoly.h | 111 + nx-X11/programs/Xserver/mi/mifpolycon.c | 284 + nx-X11/programs/Xserver/mi/migc.c | 301 + nx-X11/programs/Xserver/mi/migc.h | 74 + nx-X11/programs/Xserver/mi/miglblt.c | 255 + nx-X11/programs/Xserver/mi/miinitext.c | 799 +++ nx-X11/programs/Xserver/mi/miline.h | 174 + nx-X11/programs/Xserver/mi/mioverlay.c | 2079 +++++++ nx-X11/programs/Xserver/mi/mioverlay.h | 33 + nx-X11/programs/Xserver/mi/mipointer.c | 544 ++ nx-X11/programs/Xserver/mi/mipointer.h | 162 + nx-X11/programs/Xserver/mi/mipointrst.h | 64 + nx-X11/programs/Xserver/mi/mipoly.c | 129 + nx-X11/programs/Xserver/mi/mipoly.h | 217 + nx-X11/programs/Xserver/mi/mipolycon.c | 248 + nx-X11/programs/Xserver/mi/mipolygen.c | 232 + nx-X11/programs/Xserver/mi/mipolypnt.c | 125 + nx-X11/programs/Xserver/mi/mipolyrect.c | 193 + nx-X11/programs/Xserver/mi/mipolyseg.c | 85 + nx-X11/programs/Xserver/mi/mipolytext.c | 202 + nx-X11/programs/Xserver/mi/mipolyutil.c | 401 ++ nx-X11/programs/Xserver/mi/mipushpxl.c | 261 + nx-X11/programs/Xserver/mi/miregion.c | 2563 ++++++++ nx-X11/programs/Xserver/mi/miscanfill.h | 148 + nx-X11/programs/Xserver/mi/miscrinit.c | 372 ++ nx-X11/programs/Xserver/mi/mispans.c | 563 ++ nx-X11/programs/Xserver/mi/mispans.h | 117 + nx-X11/programs/Xserver/mi/misprite.c | 831 +++ nx-X11/programs/Xserver/mi/misprite.h | 96 + nx-X11/programs/Xserver/mi/mispritest.h | 134 + nx-X11/programs/Xserver/mi/mistruct.h | 65 + nx-X11/programs/Xserver/mi/mivalidate.h | 55 + nx-X11/programs/Xserver/mi/mivaltree.c | 826 +++ nx-X11/programs/Xserver/mi/miwideline.c | 2242 +++++++ nx-X11/programs/Xserver/mi/miwideline.h | 224 + nx-X11/programs/Xserver/mi/miwindow.c | 1184 ++++ nx-X11/programs/Xserver/mi/mizerarc.c | 855 +++ nx-X11/programs/Xserver/mi/mizerarc.h | 134 + nx-X11/programs/Xserver/mi/mizerclip.c | 636 ++ nx-X11/programs/Xserver/mi/mizerline.c | 380 ++ nx-X11/programs/Xserver/miext/cw/Imakefile | 22 + nx-X11/programs/Xserver/miext/cw/cw.c | 699 +++ nx-X11/programs/Xserver/miext/cw/cw.h | 174 + nx-X11/programs/Xserver/miext/cw/cw_ops.c | 470 ++ nx-X11/programs/Xserver/miext/cw/cw_render.c | 501 ++ nx-X11/programs/Xserver/miext/damage/Imakefile | 26 + nx-X11/programs/Xserver/miext/damage/damage.c | 1966 ++++++ nx-X11/programs/Xserver/miext/damage/damage.h | 84 + nx-X11/programs/Xserver/miext/damage/damagestr.h | 113 + nx-X11/programs/Xserver/miext/layer/Imakefile | 49 + nx-X11/programs/Xserver/miext/layer/layer.h | 149 + nx-X11/programs/Xserver/miext/layer/layergc.c | 194 + nx-X11/programs/Xserver/miext/layer/layerinit.c | 363 ++ nx-X11/programs/Xserver/miext/layer/layerpict.c | 149 + nx-X11/programs/Xserver/miext/layer/layerstr.h | 425 ++ nx-X11/programs/Xserver/miext/layer/layerwin.c | 487 ++ nx-X11/programs/Xserver/miext/layer/laymodule.c | 60 + nx-X11/programs/Xserver/miext/rootless/Imakefile | 54 + .../Xserver/miext/rootless/Imakefile.NX.original | 54 + .../Xserver/miext/rootless/Imakefile.X.original | 54 + nx-X11/programs/Xserver/miext/rootless/README.txt | 403 ++ .../Xserver/miext/rootless/accel/Imakefile | 30 + .../Xserver/miext/rootless/accel/rlAccel.c | 155 + .../Xserver/miext/rootless/accel/rlAccel.h | 141 + .../programs/Xserver/miext/rootless/accel/rlBlt.c | 370 ++ .../programs/Xserver/miext/rootless/accel/rlCopy.c | 107 + .../programs/Xserver/miext/rootless/accel/rlFill.c | 221 + .../Xserver/miext/rootless/accel/rlFillRect.c | 118 + .../Xserver/miext/rootless/accel/rlFillSpans.c | 106 + .../Xserver/miext/rootless/accel/rlGlyph.c | 170 + .../Xserver/miext/rootless/accel/rlSolid.c | 112 + nx-X11/programs/Xserver/miext/rootless/rootless.h | 436 ++ .../Xserver/miext/rootless/rootlessCommon.c | 405 ++ .../Xserver/miext/rootless/rootlessCommon.h | 261 + .../Xserver/miext/rootless/rootlessConfig.h | 68 + .../programs/Xserver/miext/rootless/rootlessGC.c | 1508 +++++ .../Xserver/miext/rootless/rootlessScreen.c | 670 +++ .../Xserver/miext/rootless/rootlessValTree.c | 648 ++ .../Xserver/miext/rootless/rootlessWindow.c | 1468 +++++ .../Xserver/miext/rootless/rootlessWindow.h | 64 + .../Xserver/miext/rootless/safeAlpha/Imakefile | 18 + .../Xserver/miext/rootless/safeAlpha/safeAlpha.h | 45 + .../miext/rootless/safeAlpha/safeAlphaPicture.c | 643 ++ .../miext/rootless/safeAlpha/safeAlphaWindow.c | 175 + nx-X11/programs/Xserver/miext/shadow/Imakefile | 66 + nx-X11/programs/Xserver/miext/shadow/shadow.c | 1544 +++++ nx-X11/programs/Xserver/miext/shadow/shadow.h | 179 + nx-X11/programs/Xserver/miext/shadow/shalloc.c | 52 + nx-X11/programs/Xserver/miext/shadow/shmodule.c | 60 + nx-X11/programs/Xserver/miext/shadow/shpacked.c | 114 + nx-X11/programs/Xserver/miext/shadow/shplanar.c | 179 + nx-X11/programs/Xserver/miext/shadow/shplanar8.c | 174 + nx-X11/programs/Xserver/miext/shadow/shrot16pack.c | 32 + .../Xserver/miext/shadow/shrot16pack_180.c | 33 + .../Xserver/miext/shadow/shrot16pack_270.c | 33 + .../programs/Xserver/miext/shadow/shrot16pack_90.c | 33 + nx-X11/programs/Xserver/miext/shadow/shrot32pack.c | 32 + .../Xserver/miext/shadow/shrot32pack_180.c | 33 + .../Xserver/miext/shadow/shrot32pack_270.c | 33 + .../programs/Xserver/miext/shadow/shrot32pack_90.c | 33 + nx-X11/programs/Xserver/miext/shadow/shrot8pack.c | 32 + .../programs/Xserver/miext/shadow/shrot8pack_180.c | 33 + .../programs/Xserver/miext/shadow/shrot8pack_270.c | 33 + .../programs/Xserver/miext/shadow/shrot8pack_90.c | 33 + nx-X11/programs/Xserver/miext/shadow/shrotate.c | 314 + nx-X11/programs/Xserver/miext/shadow/shrotpack.h | 186 + nx-X11/programs/Xserver/os/Imakefile | 235 + nx-X11/programs/Xserver/os/Imakefile.NX.original | 235 + nx-X11/programs/Xserver/os/Imakefile.X.original | 200 + nx-X11/programs/Xserver/os/WaitFor.c | 882 +++ nx-X11/programs/Xserver/os/WaitFor.c.NX.original | 882 +++ nx-X11/programs/Xserver/os/WaitFor.c.X.original | 701 +++ nx-X11/programs/Xserver/os/access.c | 2429 ++++++++ nx-X11/programs/Xserver/os/auth.c | 608 ++ nx-X11/programs/Xserver/os/auth.c.NX.original | 608 ++ nx-X11/programs/Xserver/os/auth.c.X.original | 400 ++ nx-X11/programs/Xserver/os/connection.c | 1424 +++++ .../programs/Xserver/os/connection.c.NX.original | 1424 +++++ nx-X11/programs/Xserver/os/connection.c.X.original | 1385 +++++ nx-X11/programs/Xserver/os/io.c | 1347 +++++ nx-X11/programs/Xserver/os/k5auth.c | 801 +++ nx-X11/programs/Xserver/os/lbxio.c | 555 ++ nx-X11/programs/Xserver/os/log.c | 716 +++ nx-X11/programs/Xserver/os/log.c.NX.original | 716 +++ nx-X11/programs/Xserver/os/log.c.X.original | 633 ++ nx-X11/programs/Xserver/os/mitauth.c | 199 + nx-X11/programs/Xserver/os/oscolor.c | 483 ++ nx-X11/programs/Xserver/os/oscolor.c.NX.original | 483 ++ nx-X11/programs/Xserver/os/oscolor.c.X.original | 303 + nx-X11/programs/Xserver/os/osdep.h | 358 ++ nx-X11/programs/Xserver/os/osinit.c | 246 + nx-X11/programs/Xserver/os/rpcauth.c | 204 + nx-X11/programs/Xserver/os/secauth.c | 205 + nx-X11/programs/Xserver/os/utils.c | 2427 ++++++++ nx-X11/programs/Xserver/os/utils.c.NX.original | 2427 ++++++++ nx-X11/programs/Xserver/os/utils.c.X.original | 2296 +++++++ nx-X11/programs/Xserver/os/xalloc.c | 817 +++ nx-X11/programs/Xserver/os/xdmauth.c | 502 ++ nx-X11/programs/Xserver/os/xdmcp.c | 1710 ++++++ nx-X11/programs/Xserver/os/xdmcp.c.NX.original | 1710 ++++++ nx-X11/programs/Xserver/os/xdmcp.c.X.original | 1681 ++++++ nx-X11/programs/Xserver/os/xprintf.c | 104 + nx-X11/programs/Xserver/randr/Imakefile | 18 + nx-X11/programs/Xserver/randr/mirandr.c | 102 + nx-X11/programs/Xserver/randr/randr.c | 1319 +++++ nx-X11/programs/Xserver/randr/randrstr.h | 142 + nx-X11/programs/Xserver/record/Imakefile | 33 + nx-X11/programs/Xserver/record/module/Imakefile | 34 + nx-X11/programs/Xserver/record/record.c | 3053 ++++++++++ nx-X11/programs/Xserver/record/recordmod.c | 46 + nx-X11/programs/Xserver/record/set.c | 710 +++ nx-X11/programs/Xserver/record/set.h | 150 + nx-X11/programs/Xserver/render/Imakefile | 46 + nx-X11/programs/Xserver/render/animcur.c | 402 ++ nx-X11/programs/Xserver/render/filter.c | 303 + nx-X11/programs/Xserver/render/glyph.c | 478 ++ nx-X11/programs/Xserver/render/glyphstr.h | 148 + nx-X11/programs/Xserver/render/miglyph.c | 243 + nx-X11/programs/Xserver/render/miindex.c | 357 ++ nx-X11/programs/Xserver/render/mipict.c | 629 ++ nx-X11/programs/Xserver/render/mipict.h | 213 + nx-X11/programs/Xserver/render/mirect.c | 186 + nx-X11/programs/Xserver/render/mitrap.c | 190 + nx-X11/programs/Xserver/render/mitri.c | 192 + nx-X11/programs/Xserver/render/picture.c | 1864 ++++++ nx-X11/programs/Xserver/render/picture.h | 238 + nx-X11/programs/Xserver/render/picturestr.h | 654 ++ nx-X11/programs/Xserver/render/render.c | 3306 +++++++++++ nx-X11/programs/Xserver/render/renderedge.c | 201 + nx-X11/programs/Xserver/render/renderedge.h | 120 + nx-X11/programs/Xserver/xfixes/Imakefile | 17 + nx-X11/programs/Xserver/xfixes/cursor.c | 754 +++ .../programs/Xserver/xfixes/cursor.c.NX.original | 754 +++ nx-X11/programs/Xserver/xfixes/cursor.c.X.original | 753 +++ nx-X11/programs/Xserver/xfixes/region.c | 864 +++ nx-X11/programs/Xserver/xfixes/saveset.c | 79 + nx-X11/programs/Xserver/xfixes/select.c | 281 + .../programs/Xserver/xfixes/select.c.NX.original | 281 + nx-X11/programs/Xserver/xfixes/select.c.X.original | 279 + nx-X11/programs/Xserver/xfixes/xfixes.c | 231 + nx-X11/programs/Xserver/xfixes/xfixes.h | 54 + nx-X11/programs/Xserver/xfixes/xfixesint.h | 243 + nx-X11/programs/Xserver/xkb/Imakefile | 106 + nx-X11/programs/Xserver/xkb/Imakefile.NX.original | 106 + nx-X11/programs/Xserver/xkb/Imakefile.X.original | 102 + nx-X11/programs/Xserver/xkb/ddxBeep.c | 370 ++ nx-X11/programs/Xserver/xkb/ddxConfig.c | 215 + nx-X11/programs/Xserver/xkb/ddxCtrls.c | 131 + nx-X11/programs/Xserver/xkb/ddxDevBtn.c | 102 + nx-X11/programs/Xserver/xkb/ddxFakeBtn.c | 61 + nx-X11/programs/Xserver/xkb/ddxFakeMtn.c | 122 + nx-X11/programs/Xserver/xkb/ddxInit.c | 48 + nx-X11/programs/Xserver/xkb/ddxKeyClick.c | 52 + nx-X11/programs/Xserver/xkb/ddxKillSrv.c | 61 + nx-X11/programs/Xserver/xkb/ddxLEDs.c | 74 + nx-X11/programs/Xserver/xkb/ddxList.c | 304 + nx-X11/programs/Xserver/xkb/ddxLoad.c | 965 +++ nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original | 965 +++ nx-X11/programs/Xserver/xkb/ddxLoad.c.X.original | 604 ++ nx-X11/programs/Xserver/xkb/ddxPrivate.c | 46 + nx-X11/programs/Xserver/xkb/ddxVT.c | 72 + nx-X11/programs/Xserver/xkb/xkb.c | 6233 ++++++++++++++++++++ nx-X11/programs/Xserver/xkb/xkb.h | 72 + nx-X11/programs/Xserver/xkb/xkbAccessX.c | 754 +++ nx-X11/programs/Xserver/xkb/xkbActions.c | 1432 +++++ nx-X11/programs/Xserver/xkb/xkbDflts.h | 524 ++ nx-X11/programs/Xserver/xkb/xkbDflts.h.NX.original | 524 ++ nx-X11/programs/Xserver/xkb/xkbDflts.h.X.original | 513 ++ nx-X11/programs/Xserver/xkb/xkbEvents.c | 1057 ++++ nx-X11/programs/Xserver/xkb/xkbInit.c | 1037 ++++ nx-X11/programs/Xserver/xkb/xkbLEDs.c | 1067 ++++ nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c | 188 + nx-X11/programs/Xserver/xkb/xkbPrOtherEv.c | 84 + nx-X11/programs/Xserver/xkb/xkbSwap.c | 597 ++ nx-X11/programs/Xserver/xkb/xkbUtils.c | 987 ++++ 2234 files changed, 753904 insertions(+) create mode 100644 nx-X11/programs/Xserver/GL/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/apple/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/apple/aglGlx.c create mode 100644 nx-X11/programs/Xserver/GL/apple/indirect.c create mode 100644 nx-X11/programs/Xserver/GL/dri/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/dri/Imakefile.NX.reference create mode 100644 nx-X11/programs/Xserver/GL/dri/Imakefile.XF86.reference create mode 100644 nx-X11/programs/Xserver/GL/dri/dri-def.cpp create mode 100644 nx-X11/programs/Xserver/GL/dri/dri.c create mode 100644 nx-X11/programs/Xserver/GL/dri/dri.h create mode 100644 nx-X11/programs/Xserver/GL/dri/drimodule.c create mode 100644 nx-X11/programs/Xserver/GL/dri/dristruct.h create mode 100644 nx-X11/programs/Xserver/GL/dri/sarea.h create mode 100644 nx-X11/programs/Xserver/GL/dri/xf86dri.c create mode 100644 nx-X11/programs/Xserver/GL/glx/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/glx/g_disptab.c create mode 100644 nx-X11/programs/Xserver/GL/glx/g_disptab.h create mode 100644 nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.c create mode 100644 nx-X11/programs/Xserver/GL/glx/g_disptab_EXT.h create mode 100644 nx-X11/programs/Xserver/GL/glx/g_render.c create mode 100644 nx-X11/programs/Xserver/GL/glx/g_renderswap.c create mode 100644 nx-X11/programs/Xserver/GL/glx/g_single.c create mode 100644 nx-X11/programs/Xserver/GL/glx/g_singleswap.c create mode 100644 nx-X11/programs/Xserver/GL/glx/global.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glx-def.cpp create mode 100644 nx-X11/programs/Xserver/GL/glx/glxbuf.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glxbuf.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxcmds.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glxcmdsswap.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glxcontext.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxdrawable.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxerror.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxext.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glxext.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxfb.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glxfb.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glximports.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glximports.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxmem.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glxmem.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxpix.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glxpix.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxscreens.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glxscreens.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxserver.h create mode 100644 nx-X11/programs/Xserver/GL/glx/glxutil.c create mode 100644 nx-X11/programs/Xserver/GL/glx/glxutil.h create mode 100644 nx-X11/programs/Xserver/GL/glx/impsize.h create mode 100644 nx-X11/programs/Xserver/GL/glx/module/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/glx/render2.c create mode 100644 nx-X11/programs/Xserver/GL/glx/render2swap.c create mode 100644 nx-X11/programs/Xserver/GL/glx/renderpix.c create mode 100644 nx-X11/programs/Xserver/GL/glx/renderpixswap.c create mode 100644 nx-X11/programs/Xserver/GL/glx/rensize.c create mode 100644 nx-X11/programs/Xserver/GL/glx/rensizetab.c create mode 100644 nx-X11/programs/Xserver/GL/glx/single2.c create mode 100644 nx-X11/programs/Xserver/GL/glx/single2swap.c create mode 100644 nx-X11/programs/Xserver/GL/glx/singlepix.c create mode 100644 nx-X11/programs/Xserver/GL/glx/singlepixswap.c create mode 100644 nx-X11/programs/Xserver/GL/glx/singlesize.c create mode 100644 nx-X11/programs/Xserver/GL/glx/singlesize.h create mode 100644 nx-X11/programs/Xserver/GL/glx/unpack.h create mode 100644 nx-X11/programs/Xserver/GL/glx/xfont.c create mode 100644 nx-X11/programs/Xserver/GL/glxmodule.c create mode 100644 nx-X11/programs/Xserver/GL/include/GL/glx_ansic.h create mode 100644 nx-X11/programs/Xserver/GL/include/GL/xf86glx.h create mode 100644 nx-X11/programs/Xserver/GL/mesa/GLcore/GLcore-def.cpp create mode 100644 nx-X11/programs/Xserver/GL/mesa/GLcore/GLcoremodule.c create mode 100644 nx-X11/programs/Xserver/GL/mesa/GLcore/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/GLcore/module/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/X/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/X/module/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/X/xf86glx.c create mode 100644 nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.c create mode 100644 nx-X11/programs/Xserver/GL/mesa/X/xf86glx_util.h create mode 100644 nx-X11/programs/Xserver/GL/mesa/X/xf86glxint.h create mode 100644 nx-X11/programs/Xserver/GL/mesa/array_cache/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/array_cache/module/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/main/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/main/module/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/math/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/math/module/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/shader/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/shader/grammar/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/shader/slang/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/shader/slang/library/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/swrast/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/swrast/module/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/swrast_setup/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/swrast_setup/module/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/tnl/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/mesa/tnl/module/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/opengl/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/windows/ChangeLog create mode 100755 nx-X11/programs/Xserver/GL/windows/Imakefile create mode 100644 nx-X11/programs/Xserver/GL/windows/glwindows.h create mode 100755 nx-X11/programs/Xserver/GL/windows/glwrap.c create mode 100755 nx-X11/programs/Xserver/GL/windows/indirect.c create mode 100644 nx-X11/programs/Xserver/Imakefile create mode 100644 nx-X11/programs/Xserver/Imakefile.NX.original create mode 100644 nx-X11/programs/Xserver/Imakefile.X.original create mode 100644 nx-X11/programs/Xserver/XFree86.def create mode 100644 nx-X11/programs/Xserver/XTrap/Imakefile create mode 100644 nx-X11/programs/Xserver/XTrap/module/Imakefile create mode 100644 nx-X11/programs/Xserver/XTrap/xf86XTrapModule.c create mode 100644 nx-X11/programs/Xserver/XTrap/xtrapddmi.c create mode 100644 nx-X11/programs/Xserver/XTrap/xtrapdi.c create mode 100644 nx-X11/programs/Xserver/XTrap/xtrapdiswp.c create mode 100644 nx-X11/programs/Xserver/XTrap/xtrapditbl.c create mode 100644 nx-X11/programs/Xserver/Xext/EVI.c create mode 100644 nx-X11/programs/Xserver/Xext/EVIstruct.h create mode 100644 nx-X11/programs/Xserver/Xext/Imakefile create mode 100644 nx-X11/programs/Xserver/Xext/Imakefile.NX.original create mode 100644 nx-X11/programs/Xserver/Xext/Imakefile.X.original create mode 100644 nx-X11/programs/Xserver/Xext/SecurityPolicy create mode 100644 nx-X11/programs/Xserver/Xext/appgroup.c create mode 100644 nx-X11/programs/Xserver/Xext/appgroup.h create mode 100644 nx-X11/programs/Xserver/Xext/bigreq.c create mode 100644 nx-X11/programs/Xserver/Xext/cup.c create mode 100644 nx-X11/programs/Xserver/Xext/dgaproc.h create mode 100644 nx-X11/programs/Xserver/Xext/dmx.c create mode 100644 nx-X11/programs/Xserver/Xext/dpms.c create mode 100644 nx-X11/programs/Xserver/Xext/dpmsproc.h create mode 100644 nx-X11/programs/Xserver/Xext/dpmsstubs.c create mode 100644 nx-X11/programs/Xserver/Xext/extmod/Imakefile create mode 100644 nx-X11/programs/Xserver/Xext/extmod/modinit.c create mode 100644 nx-X11/programs/Xserver/Xext/extmod/modinit.h create mode 100644 nx-X11/programs/Xserver/Xext/fontcache.c create mode 100644 nx-X11/programs/Xserver/Xext/mbuf.c create mode 100644 nx-X11/programs/Xserver/Xext/mbufbf.c create mode 100644 nx-X11/programs/Xserver/Xext/mbufpx.c create mode 100644 nx-X11/programs/Xserver/Xext/mitmisc.c create mode 100644 nx-X11/programs/Xserver/Xext/panoramiX.c create mode 100644 nx-X11/programs/Xserver/Xext/panoramiX.h create mode 100644 nx-X11/programs/Xserver/Xext/panoramiXSwap.c create mode 100644 nx-X11/programs/Xserver/Xext/panoramiXh.h create mode 100644 nx-X11/programs/Xserver/Xext/panoramiXprocs.c create mode 100644 nx-X11/programs/Xserver/Xext/panoramiXsrv.h create mode 100644 nx-X11/programs/Xserver/Xext/sampleEVI.c create mode 100644 nx-X11/programs/Xserver/Xext/saver.c create mode 100644 nx-X11/programs/Xserver/Xext/security.c create mode 100644 nx-X11/programs/Xserver/Xext/security.c.NX.original create mode 100644 nx-X11/programs/Xserver/Xext/security.c.X.original create mode 100644 nx-X11/programs/Xserver/Xext/shape.c create mode 100644 nx-X11/programs/Xserver/Xext/shm.c create mode 100644 nx-X11/programs/Xserver/Xext/sleepuntil.c create mode 100644 nx-X11/programs/Xserver/Xext/sleepuntil.h create mode 100644 nx-X11/programs/Xserver/Xext/sync.c create mode 100644 nx-X11/programs/Xserver/Xext/vidmodeproc.h create mode 100644 nx-X11/programs/Xserver/Xext/xcmisc.c create mode 100644 nx-X11/programs/Xserver/Xext/xevie.c create mode 100644 nx-X11/programs/Xserver/Xext/xf86bigfont.c create mode 100644 nx-X11/programs/Xserver/Xext/xf86dga.c create mode 100644 nx-X11/programs/Xserver/Xext/xf86dga2.c create mode 100644 nx-X11/programs/Xserver/Xext/xf86dgaext.h create mode 100644 nx-X11/programs/Xserver/Xext/xf86misc.c create mode 100644 nx-X11/programs/Xserver/Xext/xf86miscproc.h create mode 100644 nx-X11/programs/Xserver/Xext/xf86vmode.c create mode 100644 nx-X11/programs/Xserver/Xext/xprint.c create mode 100644 nx-X11/programs/Xserver/Xext/xres.c create mode 100644 nx-X11/programs/Xserver/Xext/xtest.c create mode 100644 nx-X11/programs/Xserver/Xext/xtest1.frags create mode 100644 nx-X11/programs/Xserver/Xext/xtest1dd.c create mode 100644 nx-X11/programs/Xserver/Xext/xtest1dd.h create mode 100644 nx-X11/programs/Xserver/Xext/xtest1di.c create mode 100644 nx-X11/programs/Xserver/Xext/xvdisp.c create mode 100644 nx-X11/programs/Xserver/Xext/xvdisp.h create mode 100644 nx-X11/programs/Xserver/Xext/xvdix.h create mode 100644 nx-X11/programs/Xserver/Xext/xvmain.c create mode 100644 nx-X11/programs/Xserver/Xext/xvmc.c create mode 100644 nx-X11/programs/Xserver/Xext/xvmcext.h create mode 100644 nx-X11/programs/Xserver/Xext/xvmod.c create mode 100644 nx-X11/programs/Xserver/Xext/xvmodproc.h create mode 100644 nx-X11/programs/Xserver/Xi/Imakefile create mode 100644 nx-X11/programs/Xserver/Xi/allowev.c create mode 100644 nx-X11/programs/Xserver/Xi/allowev.h create mode 100644 nx-X11/programs/Xserver/Xi/chgdctl.c create mode 100644 nx-X11/programs/Xserver/Xi/chgdctl.h create mode 100644 nx-X11/programs/Xserver/Xi/chgfctl.c create mode 100644 nx-X11/programs/Xserver/Xi/chgfctl.h create mode 100644 nx-X11/programs/Xserver/Xi/chgkbd.c create mode 100644 nx-X11/programs/Xserver/Xi/chgkbd.h create mode 100644 nx-X11/programs/Xserver/Xi/chgkmap.c create mode 100644 nx-X11/programs/Xserver/Xi/chgkmap.h create mode 100644 nx-X11/programs/Xserver/Xi/chgprop.c create mode 100644 nx-X11/programs/Xserver/Xi/chgprop.h create mode 100644 nx-X11/programs/Xserver/Xi/chgptr.c create mode 100644 nx-X11/programs/Xserver/Xi/chgptr.h create mode 100644 nx-X11/programs/Xserver/Xi/closedev.c create mode 100644 nx-X11/programs/Xserver/Xi/closedev.h create mode 100644 nx-X11/programs/Xserver/Xi/devbell.c create mode 100644 nx-X11/programs/Xserver/Xi/devbell.h create mode 100644 nx-X11/programs/Xserver/Xi/exevents.c create mode 100644 nx-X11/programs/Xserver/Xi/exglobals.h create mode 100644 nx-X11/programs/Xserver/Xi/extinit.c create mode 100644 nx-X11/programs/Xserver/Xi/getbmap.c create mode 100644 nx-X11/programs/Xserver/Xi/getbmap.h create mode 100644 nx-X11/programs/Xserver/Xi/getdctl.c create mode 100644 nx-X11/programs/Xserver/Xi/getdctl.h create mode 100644 nx-X11/programs/Xserver/Xi/getfctl.c create mode 100644 nx-X11/programs/Xserver/Xi/getfctl.h create mode 100644 nx-X11/programs/Xserver/Xi/getfocus.c create mode 100644 nx-X11/programs/Xserver/Xi/getfocus.h create mode 100644 nx-X11/programs/Xserver/Xi/getkmap.c create mode 100644 nx-X11/programs/Xserver/Xi/getkmap.h create mode 100644 nx-X11/programs/Xserver/Xi/getmmap.c create mode 100644 nx-X11/programs/Xserver/Xi/getmmap.h create mode 100644 nx-X11/programs/Xserver/Xi/getprop.c create mode 100644 nx-X11/programs/Xserver/Xi/getprop.h create mode 100644 nx-X11/programs/Xserver/Xi/getselev.c create mode 100644 nx-X11/programs/Xserver/Xi/getselev.h create mode 100644 nx-X11/programs/Xserver/Xi/getvers.c create mode 100644 nx-X11/programs/Xserver/Xi/getvers.h create mode 100644 nx-X11/programs/Xserver/Xi/grabdev.c create mode 100644 nx-X11/programs/Xserver/Xi/grabdev.h create mode 100644 nx-X11/programs/Xserver/Xi/grabdevb.c create mode 100644 nx-X11/programs/Xserver/Xi/grabdevb.h create mode 100644 nx-X11/programs/Xserver/Xi/grabdevk.c create mode 100644 nx-X11/programs/Xserver/Xi/grabdevk.h create mode 100644 nx-X11/programs/Xserver/Xi/gtmotion.c create mode 100644 nx-X11/programs/Xserver/Xi/gtmotion.h create mode 100644 nx-X11/programs/Xserver/Xi/listdev.c create mode 100644 nx-X11/programs/Xserver/Xi/listdev.h create mode 100644 nx-X11/programs/Xserver/Xi/opendev.c create mode 100644 nx-X11/programs/Xserver/Xi/opendev.h create mode 100644 nx-X11/programs/Xserver/Xi/queryst.c create mode 100644 nx-X11/programs/Xserver/Xi/queryst.h create mode 100644 nx-X11/programs/Xserver/Xi/selectev.c create mode 100644 nx-X11/programs/Xserver/Xi/selectev.h create mode 100644 nx-X11/programs/Xserver/Xi/sendexev.c create mode 100644 nx-X11/programs/Xserver/Xi/sendexev.h create mode 100644 nx-X11/programs/Xserver/Xi/setbmap.c create mode 100644 nx-X11/programs/Xserver/Xi/setbmap.h create mode 100644 nx-X11/programs/Xserver/Xi/setdval.c create mode 100644 nx-X11/programs/Xserver/Xi/setdval.h create mode 100644 nx-X11/programs/Xserver/Xi/setfocus.c create mode 100644 nx-X11/programs/Xserver/Xi/setfocus.h create mode 100644 nx-X11/programs/Xserver/Xi/setmmap.c create mode 100644 nx-X11/programs/Xserver/Xi/setmmap.h create mode 100644 nx-X11/programs/Xserver/Xi/setmode.c create mode 100644 nx-X11/programs/Xserver/Xi/setmode.h create mode 100644 nx-X11/programs/Xserver/Xi/stubs.c create mode 100644 nx-X11/programs/Xserver/Xi/ungrdev.c create mode 100644 nx-X11/programs/Xserver/Xi/ungrdev.h create mode 100644 nx-X11/programs/Xserver/Xi/ungrdevb.c create mode 100644 nx-X11/programs/Xserver/Xi/ungrdevb.h create mode 100644 nx-X11/programs/Xserver/Xi/ungrdevk.c create mode 100644 nx-X11/programs/Xserver/Xi/ungrdevk.h create mode 100644 nx-X11/programs/Xserver/Xnest.def create mode 100644 nx-X11/programs/Xserver/Xorg.def create mode 100644 nx-X11/programs/Xserver/XpConfig/C/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/Xprinters create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/attributes/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/attributes/document create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/attributes/job create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/attributes/printer create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/pcl create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/ddx-config/raster/postscript create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/fonts/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/CANONC3200-PS/model-config create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00051.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00052.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00053.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00054.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00055.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00056.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00057.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00058.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00059.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00060.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00061.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00062.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00063.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00064.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00065.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00066.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00067.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00068.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00069.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00070.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00071.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00072.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00073.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00074.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00075.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00076.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00077.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00079.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00080.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00081.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00082.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00083.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00084.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00085.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00086.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00087.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00088.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00089.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00090.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00091.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00092.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00093.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00094.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/README create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.dir create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/lpr0ye1a.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00051.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00052.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00053.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00054.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00055.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00056.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00057.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00058.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00059.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00060.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00061.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00062.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00063.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00064.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00065.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00066.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00067.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00068.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00069.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00070.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00071.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00072.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00073.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00074.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00075.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00076.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00077.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00079.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00080.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00081.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00082.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00083.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00084.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00085.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00086.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00087.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00088.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00089.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00090.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00091.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00092.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00093.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00094.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/README create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.dir create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/lpr0ye1a.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config create mode 100755 nx-X11/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Book.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-BookOblique.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Demi.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-DemiOblique.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Bold.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-BoldOblique.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Oblique.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Bold.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-BoldOblique.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Oblique.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Book.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-BookOblique.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Demi.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-DemiOblique.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Demi.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-DemiItalic.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Light.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-LightItalic.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Symbol.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Bold.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-BoldItalic.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Italic.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Roman.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/ZapfDingbats.pmf create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config create mode 100755 nx-X11/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config create mode 100644 nx-X11/programs/Xserver/XpConfig/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/README create mode 100644 nx-X11/programs/Xserver/XpConfig/en_US/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/en_US/print/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile create mode 100644 nx-X11/programs/Xserver/XpConfig/en_US/print/attributes/document create mode 100644 nx-X11/programs/Xserver/Xprint/AttrValid.c create mode 100644 nx-X11/programs/Xserver/Xprint/AttrValid.h create mode 100644 nx-X11/programs/Xserver/Xprint/DiPrint.h create mode 100644 nx-X11/programs/Xserver/Xprint/Imakefile create mode 100644 nx-X11/programs/Xserver/Xprint/Init.c create mode 100644 nx-X11/programs/Xserver/Xprint/Oid.c create mode 100644 nx-X11/programs/Xserver/Xprint/Oid.h create mode 100644 nx-X11/programs/Xserver/Xprint/OidDefs.h create mode 100644 nx-X11/programs/Xserver/Xprint/OidStrs.h create mode 100644 nx-X11/programs/Xserver/Xprint/Util.c create mode 100644 nx-X11/programs/Xserver/Xprint/ValTree.c create mode 100644 nx-X11/programs/Xserver/Xprint/Xprt.html create mode 100644 nx-X11/programs/Xserver/Xprint/Xprt.man create mode 100644 nx-X11/programs/Xserver/Xprint/Xprt.sgml create mode 100644 nx-X11/programs/Xserver/Xprint/attributes.c create mode 100644 nx-X11/programs/Xserver/Xprint/attributes.h create mode 100644 nx-X11/programs/Xserver/Xprint/ddxInit.c create mode 100644 nx-X11/programs/Xserver/Xprint/etc/Imakefile create mode 100644 nx-X11/programs/Xserver/Xprint/etc/Xsession.d/Imakefile create mode 100644 nx-X11/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh create mode 100644 nx-X11/programs/Xserver/Xprint/etc/init.d/Imakefile create mode 100644 nx-X11/programs/Xserver/Xprint/etc/init.d/xprint.cpp create mode 100644 nx-X11/programs/Xserver/Xprint/etc/profile.d/Imakefile create mode 100644 nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.csh create mode 100644 nx-X11/programs/Xserver/Xprint/etc/profile.d/xprint.sh create mode 100644 nx-X11/programs/Xserver/Xprint/mediaSizes.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl-mono/Imakefile create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/Imakefile create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/Pcl.h create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclArc.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclArea.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclAttVal.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclAttr.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclColor.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclCursor.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclDef.h create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclFonts.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclGC.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclInit.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclLine.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclMisc.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclPixel.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclPixmap.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclPolygon.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclPrint.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclSFonts.h create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclSpans.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclText.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/PclWindow.c create mode 100644 nx-X11/programs/Xserver/Xprint/pcl/Pclmap.h create mode 100644 nx-X11/programs/Xserver/Xprint/pdf/README create mode 100644 nx-X11/programs/Xserver/Xprint/ps/Imakefile create mode 100644 nx-X11/programs/Xserver/Xprint/ps/Ps.h create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsArc.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsArea.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsAttVal.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsAttr.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsCache.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsColor.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsDef.h create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsFTFonts.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsFonts.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsGC.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsImageUtil.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsInit.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsLine.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsMisc.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsPixel.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsPixmap.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsPolygon.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsPrint.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsSpans.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsText.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/PsWindow.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/psout.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/psout.h create mode 100644 nx-X11/programs/Xserver/Xprint/ps/psout_ft.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype1.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/psout_ftpstype3.c create mode 100644 nx-X11/programs/Xserver/Xprint/ps/ttf2pt1wrap.c create mode 100644 nx-X11/programs/Xserver/Xprint/raster/Imakefile create mode 100644 nx-X11/programs/Xserver/Xprint/raster/Raster.c create mode 100644 nx-X11/programs/Xserver/Xprint/raster/Raster.h create mode 100644 nx-X11/programs/Xserver/Xprint/raster/RasterAttVal.c create mode 100644 nx-X11/programs/Xserver/Xprint/spooler.c create mode 100644 nx-X11/programs/Xserver/Xprint/spooler.h create mode 100644 nx-X11/programs/Xserver/Xprint/svg/README create mode 100644 nx-X11/programs/Xserver/Xprint/windows/README create mode 100644 nx-X11/programs/Xserver/Xserver.man create mode 100644 nx-X11/programs/Xserver/Xvfb.def create mode 100644 nx-X11/programs/Xserver/afb/Imakefile create mode 100644 nx-X11/programs/Xserver/afb/README create mode 100644 nx-X11/programs/Xserver/afb/Xdaniver.doc create mode 100644 nx-X11/programs/Xserver/afb/afb.h create mode 100644 nx-X11/programs/Xserver/afb/afbbitblt.c create mode 100644 nx-X11/programs/Xserver/afb/afbblt.c create mode 100644 nx-X11/programs/Xserver/afb/afbbres.c create mode 100644 nx-X11/programs/Xserver/afb/afbbresd.c create mode 100644 nx-X11/programs/Xserver/afb/afbbstore.c create mode 100644 nx-X11/programs/Xserver/afb/afbclip.c create mode 100644 nx-X11/programs/Xserver/afb/afbcmap.c create mode 100644 nx-X11/programs/Xserver/afb/afbfillarc.c create mode 100644 nx-X11/programs/Xserver/afb/afbfillrct.c create mode 100644 nx-X11/programs/Xserver/afb/afbfillsp.c create mode 100644 nx-X11/programs/Xserver/afb/afbfont.c create mode 100644 nx-X11/programs/Xserver/afb/afbgc.c create mode 100644 nx-X11/programs/Xserver/afb/afbgetsp.c create mode 100644 nx-X11/programs/Xserver/afb/afbhrzvert.c create mode 100644 nx-X11/programs/Xserver/afb/afbimage.c create mode 100644 nx-X11/programs/Xserver/afb/afbimggblt.c create mode 100644 nx-X11/programs/Xserver/afb/afbline.c create mode 100644 nx-X11/programs/Xserver/afb/afbmisc.c create mode 100644 nx-X11/programs/Xserver/afb/afbmodule.c create mode 100644 nx-X11/programs/Xserver/afb/afbpixmap.c create mode 100644 nx-X11/programs/Xserver/afb/afbply1rct.c create mode 100644 nx-X11/programs/Xserver/afb/afbplygblt.c create mode 100644 nx-X11/programs/Xserver/afb/afbpntarea.c create mode 100644 nx-X11/programs/Xserver/afb/afbpntwin.c create mode 100644 nx-X11/programs/Xserver/afb/afbpolypnt.c create mode 100644 nx-X11/programs/Xserver/afb/afbpushpxl.c create mode 100644 nx-X11/programs/Xserver/afb/afbscrinit.c create mode 100644 nx-X11/programs/Xserver/afb/afbsetsp.c create mode 100644 nx-X11/programs/Xserver/afb/afbtegblt.c create mode 100644 nx-X11/programs/Xserver/afb/afbtile.c create mode 100644 nx-X11/programs/Xserver/afb/afbwindow.c create mode 100644 nx-X11/programs/Xserver/afb/afbzerarc.c create mode 100644 nx-X11/programs/Xserver/cfb/Imakefile create mode 100644 nx-X11/programs/Xserver/cfb/Imakefile.inc create mode 100644 nx-X11/programs/Xserver/cfb/cfb.h create mode 100644 nx-X11/programs/Xserver/cfb/cfb16.h create mode 100644 nx-X11/programs/Xserver/cfb/cfb24.h create mode 100644 nx-X11/programs/Xserver/cfb/cfb32.h create mode 100644 nx-X11/programs/Xserver/cfb/cfb8bit.c create mode 100644 nx-X11/programs/Xserver/cfb/cfb8bit.h create mode 100644 nx-X11/programs/Xserver/cfb/cfb8line.c create mode 100644 nx-X11/programs/Xserver/cfb/cfballpriv.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbbitblt.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbblt.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbbres.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbbresd.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbbstore.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbcmap.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbcppl.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbfillarc.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbfillrct.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbfillsp.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbgc.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbgetsp.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbglblt8.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbhrzvert.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbigblt8.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbimage.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbline.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbmap.h create mode 100644 nx-X11/programs/Xserver/cfb/cfbmodule.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbmskbits.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbmskbits.h create mode 100644 nx-X11/programs/Xserver/cfb/cfbpixmap.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbply1rct.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbpntwin.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbpolypnt.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbpush8.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbrctstp8.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbrrop.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbrrop.h create mode 100644 nx-X11/programs/Xserver/cfb/cfbscrinit.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbsetsp.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbsolid.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbtab.h create mode 100644 nx-X11/programs/Xserver/cfb/cfbteblt8.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbtegblt.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbtile32.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbtileodd.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbunmap.h create mode 100644 nx-X11/programs/Xserver/cfb/cfbwindow.c create mode 100644 nx-X11/programs/Xserver/cfb/cfbzerarc.c create mode 100644 nx-X11/programs/Xserver/cfb/module/Imakefile create mode 100644 nx-X11/programs/Xserver/cfb/stip68kgnu.h create mode 100644 nx-X11/programs/Xserver/cfb/stipmips.s create mode 100644 nx-X11/programs/Xserver/cfb/stipple68k.s create mode 100644 nx-X11/programs/Xserver/cfb/stipsparc.s create mode 100644 nx-X11/programs/Xserver/cfb/stipsprc32.s create mode 100644 nx-X11/programs/Xserver/cfb16/Imakefile create mode 100644 nx-X11/programs/Xserver/cfb16/cfbmodule.c create mode 100644 nx-X11/programs/Xserver/cfb16/module/Imakefile create mode 100644 nx-X11/programs/Xserver/cfb24/Imakefile create mode 100644 nx-X11/programs/Xserver/cfb24/cfbmodule.c create mode 100644 nx-X11/programs/Xserver/cfb24/cfbrrop24.h create mode 100644 nx-X11/programs/Xserver/cfb24/module/Imakefile create mode 100644 nx-X11/programs/Xserver/cfb32/Imakefile create mode 100644 nx-X11/programs/Xserver/cfb32/cfbmodule.c create mode 100644 nx-X11/programs/Xserver/cfb32/module/Imakefile create mode 100644 nx-X11/programs/Xserver/composite/Imakefile create mode 100644 nx-X11/programs/Xserver/composite/compalloc.c create mode 100644 nx-X11/programs/Xserver/composite/compext.c create mode 100644 nx-X11/programs/Xserver/composite/compinit.c create mode 100644 nx-X11/programs/Xserver/composite/compint.h create mode 100644 nx-X11/programs/Xserver/composite/compwindow.c create mode 100644 nx-X11/programs/Xserver/damageext/Imakefile create mode 100755 nx-X11/programs/Xserver/damageext/damageext.c create mode 100644 nx-X11/programs/Xserver/damageext/damageext.h create mode 100644 nx-X11/programs/Xserver/damageext/damageextint.h create mode 100644 nx-X11/programs/Xserver/dbe/Imakefile create mode 100644 nx-X11/programs/Xserver/dbe/dbe.c create mode 100644 nx-X11/programs/Xserver/dbe/dbemodule.c create mode 100644 nx-X11/programs/Xserver/dbe/dbestruct.h create mode 100644 nx-X11/programs/Xserver/dbe/midbe.c create mode 100644 nx-X11/programs/Xserver/dbe/midbe.h create mode 100644 nx-X11/programs/Xserver/dbe/midbestr.h create mode 100644 nx-X11/programs/Xserver/dbe/module/Imakefile create mode 100644 nx-X11/programs/Xserver/dix/BuiltInAtoms create mode 100644 nx-X11/programs/Xserver/dix/CHANGES create mode 100644 nx-X11/programs/Xserver/dix/Imakefile create mode 100644 nx-X11/programs/Xserver/dix/atom.c create mode 100644 nx-X11/programs/Xserver/dix/buildatoms create mode 100644 nx-X11/programs/Xserver/dix/colormap.c create mode 100644 nx-X11/programs/Xserver/dix/cursor.c create mode 100644 nx-X11/programs/Xserver/dix/devices.c create mode 100644 nx-X11/programs/Xserver/dix/dispatch.c create mode 100644 nx-X11/programs/Xserver/dix/dispatch.h create mode 100644 nx-X11/programs/Xserver/dix/dixfonts.c create mode 100644 nx-X11/programs/Xserver/dix/dixfonts.c.NX.original create mode 100644 nx-X11/programs/Xserver/dix/dixfonts.c.X.original create mode 100644 nx-X11/programs/Xserver/dix/dixutils.c create mode 100644 nx-X11/programs/Xserver/dix/events.c create mode 100644 nx-X11/programs/Xserver/dix/extension.c create mode 100644 nx-X11/programs/Xserver/dix/ffs.c create mode 100644 nx-X11/programs/Xserver/dix/gc.c create mode 100644 nx-X11/programs/Xserver/dix/globals.c create mode 100644 nx-X11/programs/Xserver/dix/glyphcurs.c create mode 100644 nx-X11/programs/Xserver/dix/grabs.c create mode 100644 nx-X11/programs/Xserver/dix/initatoms.c create mode 100644 nx-X11/programs/Xserver/dix/main.c create mode 100644 nx-X11/programs/Xserver/dix/pixmap.c create mode 100644 nx-X11/programs/Xserver/dix/pixmap.c.NX.original create mode 100644 nx-X11/programs/Xserver/dix/pixmap.c.X.original create mode 100644 nx-X11/programs/Xserver/dix/privates.c create mode 100644 nx-X11/programs/Xserver/dix/property.c create mode 100644 nx-X11/programs/Xserver/dix/resource.c create mode 100644 nx-X11/programs/Xserver/dix/swaprep.c create mode 100644 nx-X11/programs/Xserver/dix/swapreq.c create mode 100644 nx-X11/programs/Xserver/dix/tables.c create mode 100644 nx-X11/programs/Xserver/dix/window.c create mode 100644 nx-X11/programs/Xserver/dix/xpstubs.c create mode 100644 nx-X11/programs/Xserver/fb/Imakefile create mode 100644 nx-X11/programs/Xserver/fb/Imakefile.NX.original create mode 100644 nx-X11/programs/Xserver/fb/Imakefile.X.original create mode 100644 nx-X11/programs/Xserver/fb/fb.h create mode 100644 nx-X11/programs/Xserver/fb/fb24_32.c create mode 100644 nx-X11/programs/Xserver/fb/fb24_32.h create mode 100644 nx-X11/programs/Xserver/fb/fballpriv.c create mode 100644 nx-X11/programs/Xserver/fb/fbarc.c create mode 100644 nx-X11/programs/Xserver/fb/fbbits.c create mode 100644 nx-X11/programs/Xserver/fb/fbbits.h create mode 100644 nx-X11/programs/Xserver/fb/fbblt.c create mode 100644 nx-X11/programs/Xserver/fb/fbbltone.c create mode 100644 nx-X11/programs/Xserver/fb/fbbstore.c create mode 100644 nx-X11/programs/Xserver/fb/fbcmap.c create mode 100644 nx-X11/programs/Xserver/fb/fbcompose.c create mode 100644 nx-X11/programs/Xserver/fb/fbcopy.c create mode 100644 nx-X11/programs/Xserver/fb/fbedge.c create mode 100644 nx-X11/programs/Xserver/fb/fbedgeimp.h create mode 100644 nx-X11/programs/Xserver/fb/fbfill.c create mode 100644 nx-X11/programs/Xserver/fb/fbfillrect.c create mode 100644 nx-X11/programs/Xserver/fb/fbfillsp.c create mode 100644 nx-X11/programs/Xserver/fb/fbgc.c create mode 100644 nx-X11/programs/Xserver/fb/fbgetsp.c create mode 100644 nx-X11/programs/Xserver/fb/fbglyph.c create mode 100644 nx-X11/programs/Xserver/fb/fbimage.c create mode 100644 nx-X11/programs/Xserver/fb/fbline.c create mode 100644 nx-X11/programs/Xserver/fb/fbmmx.c create mode 100644 nx-X11/programs/Xserver/fb/fbmmx.h create mode 100644 nx-X11/programs/Xserver/fb/fbmodule.c create mode 100644 nx-X11/programs/Xserver/fb/fboverlay.c create mode 100644 nx-X11/programs/Xserver/fb/fboverlay.h create mode 100644 nx-X11/programs/Xserver/fb/fbpict.c create mode 100644 nx-X11/programs/Xserver/fb/fbpict.h create mode 100644 nx-X11/programs/Xserver/fb/fbpixmap.c create mode 100644 nx-X11/programs/Xserver/fb/fbpoint.c create mode 100644 nx-X11/programs/Xserver/fb/fbpseudocolor.c create mode 100644 nx-X11/programs/Xserver/fb/fbpseudocolor.h create mode 100644 nx-X11/programs/Xserver/fb/fbpush.c create mode 100644 nx-X11/programs/Xserver/fb/fbrop.h create mode 100644 nx-X11/programs/Xserver/fb/fbscreen.c create mode 100644 nx-X11/programs/Xserver/fb/fbseg.c create mode 100644 nx-X11/programs/Xserver/fb/fbsetsp.c create mode 100644 nx-X11/programs/Xserver/fb/fbsolid.c create mode 100644 nx-X11/programs/Xserver/fb/fbstipple.c create mode 100644 nx-X11/programs/Xserver/fb/fbtile.c create mode 100644 nx-X11/programs/Xserver/fb/fbtrap.c create mode 100644 nx-X11/programs/Xserver/fb/fbutil.c create mode 100644 nx-X11/programs/Xserver/fb/fbwindow.c create mode 100644 nx-X11/programs/Xserver/fb/module/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/XDarwin.man create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Credits.rtf create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Localizable.strings create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/classes.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/objects.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Credits.rtf create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/Localizable.strings create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Credits.rtf create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Localizable.strings create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/classes.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/objects.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Credits.rtf create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Localizable.strings create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/classes.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/objects.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Credits.rtf create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Localizable.strings create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/classes.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/objects.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Credits.rtf create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Localizable.strings create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/classes.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/objects.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Credits.rtf create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Localizable.strings create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/classes.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/objects.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Credits.rtf create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Localizable.strings create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/classes.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/objects.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/XDarwin.icns create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Credits.rtf create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Localizable.strings create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/classes.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/objects.nib create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/bundle/startXClients.cpp create mode 100644 nx-X11/programs/Xserver/hw/darwin/darwin.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/darwin.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/darwinClut8.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/darwinEvents.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/darwinKeyboard.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/darwinXinput.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/iokit/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKit.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitCursor.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/iokit/xfIOKitStartup.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/Preferences.m create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/XApplication.m create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/XDarwinStartup.man create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/XServer.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/XServer.m create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/applewm.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/applewmExt.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/cr/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/cr/XView.m create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/cr/cr.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/cr/crAppleWM.m create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/cr/crFrame.m create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/cr/crScreen.m create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/fullscreen/quartzCursor.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/keysym2ucs.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/pseudoramiX.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartz.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartz.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzAudio.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzCocoa.m create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzCommon.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzCursor.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzKeyboard.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzPasteboard.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/quartzStartup.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/Xplugin.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/appledri.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dri.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/dristruct.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hash.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-hook.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/x-list.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xpr.h create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprAppleWM.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprCursor.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/utils/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/darwin/utils/README.txt create mode 100644 nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.c create mode 100644 nx-X11/programs/Xserver/hw/darwin/utils/dumpkeymap.man create mode 100644 nx-X11/programs/Xserver/hw/dmx/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/dmx/Xdmx.man create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/Canvas.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/Canvas.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/CanvasP.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/TODO create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxcompat.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxconfig.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxparse.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxparse.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxprint.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxprint.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/dmxtodmx.man create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/parser.y create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/scanner.l create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-a.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-a.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-b.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-b.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-c.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-c.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-d.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-d.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-e.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-e.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-f.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-f.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-g.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-g.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-h.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-h.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-i.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-i.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-j.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-j.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-k.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-k.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-l.in create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/test-l.out create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/vdltodmx.man create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/config/xdmxconfig.man create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmx.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmx_glxvisuals.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxcb.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxcb.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxclient.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxcmap.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxcmap.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxcursor.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxcursor.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxdpms.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxdpms.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxextension.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxextension.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxfont.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxfont.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxgc.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxgc.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxgcops.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxgcops.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxinit.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxinit.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxinput.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxinput.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxlog.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxlog.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxpict.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxpict.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxpixmap.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxpixmap.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxprop.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxprop.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxscrinit.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxscrinit.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxshadow.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxshadow.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxstat.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxstat.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxsync.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxsync.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxvisual.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxvisual.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxwindow.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/dmxwindow.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec-v1.txt create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/DMXSpec.txt create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/Makefile.linux create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/dmx.sgml create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/dmx.txt create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/doxygen.conf create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/doxygen.css create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/doxygen.foot create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/doxygen.head create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ChkNotMaskEv_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/annotated.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/classes.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmx_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmx__glxvisuals_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxarg_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxbackend_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcb_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxclient_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcmap_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcommon_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcompat_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconfig_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxconsole_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxcursor_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdetach_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdpms_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxdummy_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxeq_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxevents_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxext_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxextension_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxfont_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgc_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxgcops_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinit_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinput_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxinputinit_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxlog_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmap_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxmotion_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxparse_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpict_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxpixmap_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprint_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxprop_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxproto_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxscrinit_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxshadow_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsigio_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxstat_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxsync_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxvisual_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxwindow_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/dmxxinput_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.css create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/doxygen.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/files.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2blank.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2doc.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderclosed.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2folderopen.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2lastnode.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2link.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mlastnode.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2mnode.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2node.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2plastnode.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2pnode.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/ftv2vertline.png create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/functions.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/functions_vars.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/globals.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/globals_defs.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/globals_enum.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/globals_eval.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/globals_func.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/globals_type.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/globals_vars.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/index.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lib_2dmx_2dmx_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-keyboard_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ms_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/lnx-ps2_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/main.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/programs_2Xserver_2Xext_2dmx_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigCmdStruct.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXConfigListStruct.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributes.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXDesktopAttributesRec.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributes.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXInputAttributesRec.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributes.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXScreenAttributesRec.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributes.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structDMXWindowAttributesRec.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigComment.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigDisplay.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigEntry.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigFullDim.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigNumber.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigOption.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPair.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigParam.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigPartDim.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigString.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigSub.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigToken.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigVirtual.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXConfigWall.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXEventMap.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXInputInfo.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInitInfo.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXLocalInputInfo.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXScreenInfo.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatAvg.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__DMXStatInfo.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__Event.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__EventQueue.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxArg.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxColormapPriv.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxCursorPriv.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxFontPriv.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGCPriv.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxGlyphPriv.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPictPriv.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxPixPriv.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__dmxWinPriv.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/struct__myPrivate.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structdmxGlxVisualPrivate.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddInputReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXAddScreenReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeDesktopAttributesReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXChangeScreensAttributesReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXForceWindowCreationReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetDesktopAttributesReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputAttributesReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetInputCountReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenAttributesReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetScreenCountReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXGetWindowAttributesReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXQueryVersionReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveInputReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXRemoveScreenReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReply.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/structxDMXSyncReq.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/tree.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-common_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-keyboard_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-mouse_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8c.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-other_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h-source.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/html/usb-private_8h.html create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/scaled.sgml create mode 100644 nx-X11/programs/Xserver/hw/dmx/doc/scaled.txt create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/dmxaddinput.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/dmxaddscreen.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/dmxreconfig.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/dmxresize.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/dmxrminput.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/dmxrmscreen.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/dmxwininfo.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/ev.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/evi.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/res.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/xbell.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/xdmx.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/xinput.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/xled.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/examples/xtest.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/compsize.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/g_disptab.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/g_renderswap.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/global.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmds.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcmdsswap.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxcontext.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxdrawable.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxerror.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxext.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxfbconfig.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxscreens.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxserver.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxsingle.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxswap.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxutil.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvendor.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/glxvisuals.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/render2swap.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/renderpixswap.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/glxProxy/unpack.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/ChkNotMaskEv.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxarg.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxarg.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxbackend.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxcommon.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxconsole.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxdetach.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxdummy.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxeq.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxeq.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxevents.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxevents.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxinputinit.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxmap.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxmap.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxmotion.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxsigio.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/dmxxinput.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/lnx-keyboard.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/lnx-ms.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/lnx-ps2.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/usb-common.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/usb-common.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/usb-keyboard.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/usb-mouse.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/usb-other.c create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/usb-other.h create mode 100644 nx-X11/programs/Xserver/hw/dmx/input/usb-private.h create mode 100644 nx-X11/programs/Xserver/hw/kdrive/README create mode 100644 nx-X11/programs/Xserver/hw/sun/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/sun/README create mode 100644 nx-X11/programs/Xserver/hw/sun/Xsun.man create mode 100644 nx-X11/programs/Xserver/hw/sun/circleset.h create mode 100644 nx-X11/programs/Xserver/hw/sun/constype.c create mode 100644 nx-X11/programs/Xserver/hw/sun/constype.man create mode 100644 nx-X11/programs/Xserver/hw/sun/kbd_mode.c create mode 100644 nx-X11/programs/Xserver/hw/sun/kbd_mode.man create mode 100644 nx-X11/programs/Xserver/hw/sun/sun.h create mode 100644 nx-X11/programs/Xserver/hw/sun/sunCfb.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunCfb24.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunCursor.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunFbs.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunGX.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunGX.h create mode 100644 nx-X11/programs/Xserver/hw/sun/sunInit.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunIo.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunKbd.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunKeyMap.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunMfb.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunMouse.c create mode 100644 nx-X11/programs/Xserver/hw/sun/sunMultiDepth.c create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/btreg.h create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/btvar.h create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/fbio.h create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/patch.Console create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/patch.Console-2.4.0 create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/sun.h create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c create mode 100644 nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h create mode 100644 nx-X11/programs/Xserver/hw/vfb/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/vfb/InitInput.c create mode 100644 nx-X11/programs/Xserver/hw/vfb/InitOutput.c create mode 100644 nx-X11/programs/Xserver/hw/vfb/Xvfb.man create mode 100644 nx-X11/programs/Xserver/hw/vfb/lk201kbd.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/atKeynames.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/compiler.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/fourcc.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/modeline2c.pl create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/scoasm.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86AutoConfig.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Bus.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Config.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Configure.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Cursor.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86DGA.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86DPMS.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Debug.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86DefModes.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86DoProbe.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86DoScanPci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Events.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Globals.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Helper.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86InPriv.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86KbdMach.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Keymap.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86MiscExt.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Mode.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Module.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Opt.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Option.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86PM.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86PciInfo.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Priv.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Privstr.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86RandR.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Resources.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Versions.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86VidMode.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86XKB.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86Xinput.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86cmap.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86fbBus.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86fbman.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86isaBus.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86noBus.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86pciBus.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86sbusBus.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86str.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86xv.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86xvmc.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xf86xvpriv.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xisb.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xisb.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/common/xorgHelper.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/README.OS-lib create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/assyntax.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/arm_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsdResource.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_KbdMap.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_apm.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_axp.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_ev56.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/bsd_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/data.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/descr.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/parse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usage.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.3 create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb_hid_usages create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usbvar.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/memrange.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/ppc_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsd/sparc64_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/460gxPCI.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Pci.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/Sbus.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/altixPCI.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/axpPci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/e8870PCI.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/netbsdPci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/ppcPci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bus/zx1PCI.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/bios_DGmmap.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_kbdEv.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_tty.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/bios_mmap.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/int10Defines.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/int10/x86emu/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_KbdMap.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_acpi.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_axp.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ev56.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_font.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_ia64.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_pci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_noinline.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.S create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.S create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Delay.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.S create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/IODelay.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/PortIO.S create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.S create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/nto/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/nto/README create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/README create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_ioperm.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_kbdEv.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_select.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_stubs.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_devs.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_pci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/pmax/pmax_ppc.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_VTsw.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_select.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_utils.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/qnx4/qnx_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/VTsw_sco.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_KbdMap.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_iop.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_kbd.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/agp_noop.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/at_scancode.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/bios_mmap.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ia64Pci.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/inout.S create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/pm_noop.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigio.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sigiostubs.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdPci.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/shared/xf86Axp.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h create mode 100755 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-amd64.S create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-ia32.S create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-sparcv8plus.S create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_KbdMap.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_init.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_io.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_iop.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_kbd.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_mouse.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_vtsw.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/usl/usl_xqueue.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSKbd.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/xf86OSpriv.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/xf86_libc.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Configint.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/DRI.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Device.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Extensions.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Files.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Flags.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Input.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Keyboard.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Layout.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Module.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Monitor.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Pointer.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Screen.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Vendor.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/Video.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/configProcs.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/cpconfig.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/read.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/scan.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/write.c create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/xf86Optrec.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/xf86Parser.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/parser/xf86tokens.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/xf86Date.h create mode 100644 nx-X11/programs/Xserver/hw/xfree86/xf86Version.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Args.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Args.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Color.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Color.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Cursor.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Display.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Display.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Drawable.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Events.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Events.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Font.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/GC.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/GCOps.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/GCOps.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/GetTime.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Handlers.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Handlers.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xnest/Init.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Init.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Keyboard.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Keyboard.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Pixmap.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Pointer.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Pointer.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Screen.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Screen.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/TestExt.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Visual.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/Visual.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Window.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/XNCursor.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/XNFont.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/XNGC.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/XNPixmap.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/XNWindow.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Xnest.h create mode 100644 nx-X11/programs/Xserver/hw/xnest/Xnest.man create mode 100644 nx-X11/programs/Xserver/hw/xnest/icon create mode 100644 nx-X11/programs/Xserver/hw/xnest/os2Stub.c create mode 100644 nx-X11/programs/Xserver/hw/xnest/screensaver create mode 100644 nx-X11/programs/Xserver/hw/xwin/ChangeLog create mode 100644 nx-X11/programs/Xserver/hw/xwin/Imakefile create mode 100644 nx-X11/programs/Xserver/hw/xwin/InitInput.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/InitOutput.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/README create mode 100755 nx-X11/programs/Xserver/hw/xwin/X-boxed.ico create mode 100644 nx-X11/programs/Xserver/hw/xwin/X.ico create mode 100644 nx-X11/programs/Xserver/hw/xwin/XWin.man create mode 100644 nx-X11/programs/Xserver/hw/xwin/XWin.rc create mode 100755 nx-X11/programs/Xserver/hw/xwin/XWinrc.man create mode 100644 nx-X11/programs/Xserver/hw/xwin/_usr_X11R6_lib_X11_system.XWinrc create mode 100644 nx-X11/programs/Xserver/hw/xwin/ddraw.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/win.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/winallpriv.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winauth.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winblock.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winclip.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winclipboard.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/winclipboardinit.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winclipboardtextconv.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winclipboardthread.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winclipboardunicode.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winclipboardwndproc.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winclipboardwrappers.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winclipboardxevents.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/wincmap.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winconfig.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winconfig.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/wincreatewnd.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/wincursor.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/windialogs.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winengine.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winerror.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winfillsp.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winfont.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/wingc.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/wingetsp.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winglobals.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winkeybd.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winkeybd.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/winkeyhook.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winkeymap.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/winkeynames.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/winlayouts.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/winmessages.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/winmisc.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winmouse.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winms.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/winmsg.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winmsg.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winmultiwindowclass.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/winmultiwindowicons.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winmultiwindowshape.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winmultiwindowwindow.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winmultiwindowwm.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winmultiwindowwndproc.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winnativegdi.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winpfbdd.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winpixmap.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winpntwin.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winpolyline.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winprefs.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winprefs.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/winprefslex.l create mode 100644 nx-X11/programs/Xserver/hw/xwin/winprefsyacc.y create mode 100644 nx-X11/programs/Xserver/hw/xwin/winpriv.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winpriv.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/winprocarg.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winpushpxl.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winrandr.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winregistry.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winresource.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/winrop.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winscrinit.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winsetsp.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winshaddd.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winshadddnl.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winshadgdi.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/wintrayicon.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winvalargs.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winvideo.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winwakeup.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winwin32rootless.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winwin32rootlesswindow.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/winwin32rootlesswndproc.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winwindow.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winwindow.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/winwindowswm.c create mode 100644 nx-X11/programs/Xserver/hw/xwin/winwndproc.c create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/COPYING create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/Makefile create mode 100644 nx-X11/programs/Xserver/hw/xwin/xlaunch/config.cc create mode 100644 nx-X11/programs/Xserver/hw/xwin/xlaunch/config.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/main.cc create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/dialog.rc create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/fullscreen.bmp create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/images.rc create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/multiwindow.bmp create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/nodecoration.bmp create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/resources.rc create mode 100644 nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/strings.rc create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/resources/windowed.bmp create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.cc create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/window/dialog.h create mode 100644 nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.cc create mode 100644 nx-X11/programs/Xserver/hw/xwin/xlaunch/window/util.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.cc create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/window/window.h create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.cc create mode 100755 nx-X11/programs/Xserver/hw/xwin/xlaunch/window/wizard.h create mode 100644 nx-X11/programs/Xserver/ilbm/Imakefile create mode 100644 nx-X11/programs/Xserver/ilbm/README create mode 100644 nx-X11/programs/Xserver/ilbm/ilbm.h create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmbitblt.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmblt.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmbres.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmbresd.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmbstore.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmclip.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmcmap.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmfillarc.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmfillrct.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmfillsp.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmfont.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmgc.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmgetsp.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmhrzvert.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmimage.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmimggblt.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmline.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmmisc.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmpixmap.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmply1rct.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmplygblt.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmpntarea.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmpntwin.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmpolypnt.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmpushpxl.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmscrinit.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmsetsp.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmtegblt.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmtile.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmwindow.c create mode 100644 nx-X11/programs/Xserver/ilbm/ilbmzerarc.c create mode 100644 nx-X11/programs/Xserver/include/Imakefile create mode 100644 nx-X11/programs/Xserver/include/XIstubs.h create mode 100644 nx-X11/programs/Xserver/include/bstore.h create mode 100644 nx-X11/programs/Xserver/include/bstorestr.h create mode 100644 nx-X11/programs/Xserver/include/closestr.h create mode 100644 nx-X11/programs/Xserver/include/closure.h create mode 100644 nx-X11/programs/Xserver/include/colormap.h create mode 100644 nx-X11/programs/Xserver/include/colormapst.h create mode 100644 nx-X11/programs/Xserver/include/cursor.h create mode 100644 nx-X11/programs/Xserver/include/cursorstr.h create mode 100644 nx-X11/programs/Xserver/include/dix.h create mode 100644 nx-X11/programs/Xserver/include/dixevents.h create mode 100644 nx-X11/programs/Xserver/include/dixfont.h create mode 100644 nx-X11/programs/Xserver/include/dixfontstr.h create mode 100644 nx-X11/programs/Xserver/include/dixgrabs.h create mode 100644 nx-X11/programs/Xserver/include/dixstruct.h create mode 100644 nx-X11/programs/Xserver/include/dixstruct.h.NX.original create mode 100644 nx-X11/programs/Xserver/include/dixstruct.h.X.original create mode 100644 nx-X11/programs/Xserver/include/exevents.h create mode 100644 nx-X11/programs/Xserver/include/extension.h create mode 100644 nx-X11/programs/Xserver/include/extinit.h create mode 100644 nx-X11/programs/Xserver/include/extnsionst.h create mode 100644 nx-X11/programs/Xserver/include/gc.h create mode 100644 nx-X11/programs/Xserver/include/gcstruct.h create mode 100644 nx-X11/programs/Xserver/include/globals.h create mode 100644 nx-X11/programs/Xserver/include/input.h create mode 100644 nx-X11/programs/Xserver/include/inputstr.h create mode 100644 nx-X11/programs/Xserver/include/misc.h create mode 100644 nx-X11/programs/Xserver/include/miscstruct.h create mode 100644 nx-X11/programs/Xserver/include/opaque.h create mode 100644 nx-X11/programs/Xserver/include/os.h create mode 100644 nx-X11/programs/Xserver/include/pixmap.h create mode 100644 nx-X11/programs/Xserver/include/pixmapstr.h create mode 100644 nx-X11/programs/Xserver/include/property.h create mode 100644 nx-X11/programs/Xserver/include/propertyst.h create mode 100644 nx-X11/programs/Xserver/include/region.h create mode 100644 nx-X11/programs/Xserver/include/regionstr.h create mode 100644 nx-X11/programs/Xserver/include/resource.h create mode 100644 nx-X11/programs/Xserver/include/rgb.h create mode 100644 nx-X11/programs/Xserver/include/screenint.h create mode 100644 nx-X11/programs/Xserver/include/scrnintstr.h create mode 100644 nx-X11/programs/Xserver/include/selection.h create mode 100644 nx-X11/programs/Xserver/include/servermd.h create mode 100644 nx-X11/programs/Xserver/include/site.h create mode 100644 nx-X11/programs/Xserver/include/swaprep.h create mode 100644 nx-X11/programs/Xserver/include/swapreq.h create mode 100644 nx-X11/programs/Xserver/include/validate.h create mode 100644 nx-X11/programs/Xserver/include/window.h create mode 100644 nx-X11/programs/Xserver/include/windowstr.h create mode 100644 nx-X11/programs/Xserver/iplan2p2/Imakefile create mode 100644 nx-X11/programs/Xserver/iplan2p4/Imakefile create mode 100644 nx-X11/programs/Xserver/iplan2p4/ipl.h create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplallpriv.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplbitblt.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplblt.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplbres.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplbresd.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplbstore.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplcmap.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplfillarc.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplfillrct.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplfillsp.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplgc.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplgetsp.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplhrzvert.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplimage.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplline.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplmap.h create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplmergerop.h create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplmskbits.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplmskbits.h create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplpack.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplpack.h create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplpixmap.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplply1rct.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplpntwin.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplpolypnt.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplrrop.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplrrop.h create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplscrinit.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplsetsp.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplsolid.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/ipltegblt.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/ipltile32.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/ipltileodd.c create mode 100644 nx-X11/programs/Xserver/iplan2p4/iplwindow.c create mode 100644 nx-X11/programs/Xserver/iplan2p8/Imakefile create mode 100644 nx-X11/programs/Xserver/lbx/Imakefile create mode 100644 nx-X11/programs/Xserver/lbx/lbxcmap.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxdata.h create mode 100644 nx-X11/programs/Xserver/lbx/lbxdix.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxexts.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxgfx.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxmain.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxopts.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxprop.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxserve.h create mode 100644 nx-X11/programs/Xserver/lbx/lbxsquish.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxsrvopts.h create mode 100644 nx-X11/programs/Xserver/lbx/lbxswap.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxtables.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxtags.c create mode 100644 nx-X11/programs/Xserver/lbx/lbxtags.h create mode 100644 nx-X11/programs/Xserver/lbx/lbxzerorep.c create mode 100644 nx-X11/programs/Xserver/mfb/Imakefile create mode 100644 nx-X11/programs/Xserver/mfb/fastblt.h create mode 100644 nx-X11/programs/Xserver/mfb/maskbits.c create mode 100644 nx-X11/programs/Xserver/mfb/maskbits.h create mode 100644 nx-X11/programs/Xserver/mfb/mergerop.h create mode 100644 nx-X11/programs/Xserver/mfb/mfb.h create mode 100644 nx-X11/programs/Xserver/mfb/mfbbitblt.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbblt.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbbres.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbbresd.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbbstore.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbclip.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbcmap.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbfillarc.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbfillrct.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbfillsp.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbfont.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbgc.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbgetsp.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbhrzvert.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbimage.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbimggblt.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbline.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbmisc.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbmodule.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbpixmap.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbply1rct.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbplygblt.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbpntarea.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbpntwin.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbpolypnt.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbpushpxl.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbscrclse.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbscrinit.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbsetsp.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbtegblt.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbtile.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbwindow.c create mode 100644 nx-X11/programs/Xserver/mfb/mfbzerarc.c create mode 100644 nx-X11/programs/Xserver/mfb/module/Imakefile create mode 100644 nx-X11/programs/Xserver/mi/Imakefile create mode 100644 nx-X11/programs/Xserver/mi/Imakefile.NX.original create mode 100644 nx-X11/programs/Xserver/mi/Imakefile.X.original create mode 100644 nx-X11/programs/Xserver/mi/cbrt.c create mode 100644 nx-X11/programs/Xserver/mi/mi.h create mode 100644 nx-X11/programs/Xserver/mi/miarc.c create mode 100644 nx-X11/programs/Xserver/mi/mibank.c create mode 100644 nx-X11/programs/Xserver/mi/mibank.h create mode 100644 nx-X11/programs/Xserver/mi/mibitblt.c create mode 100644 nx-X11/programs/Xserver/mi/mibstore.c create mode 100644 nx-X11/programs/Xserver/mi/mibstore.h create mode 100644 nx-X11/programs/Xserver/mi/mibstorest.h create mode 100644 nx-X11/programs/Xserver/mi/miclipn.c create mode 100644 nx-X11/programs/Xserver/mi/micmap.c create mode 100644 nx-X11/programs/Xserver/mi/micmap.h create mode 100644 nx-X11/programs/Xserver/mi/micoord.h create mode 100644 nx-X11/programs/Xserver/mi/micursor.c create mode 100644 nx-X11/programs/Xserver/mi/midash.c create mode 100644 nx-X11/programs/Xserver/mi/midispcur.c create mode 100644 nx-X11/programs/Xserver/mi/mieq.c create mode 100644 nx-X11/programs/Xserver/mi/miexpose.c create mode 100644 nx-X11/programs/Xserver/mi/mifillarc.c create mode 100644 nx-X11/programs/Xserver/mi/mifillarc.h create mode 100644 nx-X11/programs/Xserver/mi/mifillrct.c create mode 100644 nx-X11/programs/Xserver/mi/mifpoly.h create mode 100644 nx-X11/programs/Xserver/mi/mifpolycon.c create mode 100644 nx-X11/programs/Xserver/mi/migc.c create mode 100644 nx-X11/programs/Xserver/mi/migc.h create mode 100644 nx-X11/programs/Xserver/mi/miglblt.c create mode 100644 nx-X11/programs/Xserver/mi/miinitext.c create mode 100644 nx-X11/programs/Xserver/mi/miline.h create mode 100644 nx-X11/programs/Xserver/mi/mioverlay.c create mode 100644 nx-X11/programs/Xserver/mi/mioverlay.h create mode 100644 nx-X11/programs/Xserver/mi/mipointer.c create mode 100644 nx-X11/programs/Xserver/mi/mipointer.h create mode 100644 nx-X11/programs/Xserver/mi/mipointrst.h create mode 100644 nx-X11/programs/Xserver/mi/mipoly.c create mode 100644 nx-X11/programs/Xserver/mi/mipoly.h create mode 100644 nx-X11/programs/Xserver/mi/mipolycon.c create mode 100644 nx-X11/programs/Xserver/mi/mipolygen.c create mode 100644 nx-X11/programs/Xserver/mi/mipolypnt.c create mode 100644 nx-X11/programs/Xserver/mi/mipolyrect.c create mode 100644 nx-X11/programs/Xserver/mi/mipolyseg.c create mode 100644 nx-X11/programs/Xserver/mi/mipolytext.c create mode 100644 nx-X11/programs/Xserver/mi/mipolyutil.c create mode 100644 nx-X11/programs/Xserver/mi/mipushpxl.c create mode 100644 nx-X11/programs/Xserver/mi/miregion.c create mode 100644 nx-X11/programs/Xserver/mi/miscanfill.h create mode 100644 nx-X11/programs/Xserver/mi/miscrinit.c create mode 100644 nx-X11/programs/Xserver/mi/mispans.c create mode 100644 nx-X11/programs/Xserver/mi/mispans.h create mode 100644 nx-X11/programs/Xserver/mi/misprite.c create mode 100644 nx-X11/programs/Xserver/mi/misprite.h create mode 100644 nx-X11/programs/Xserver/mi/mispritest.h create mode 100644 nx-X11/programs/Xserver/mi/mistruct.h create mode 100644 nx-X11/programs/Xserver/mi/mivalidate.h create mode 100644 nx-X11/programs/Xserver/mi/mivaltree.c create mode 100644 nx-X11/programs/Xserver/mi/miwideline.c create mode 100644 nx-X11/programs/Xserver/mi/miwideline.h create mode 100644 nx-X11/programs/Xserver/mi/miwindow.c create mode 100644 nx-X11/programs/Xserver/mi/mizerarc.c create mode 100644 nx-X11/programs/Xserver/mi/mizerarc.h create mode 100644 nx-X11/programs/Xserver/mi/mizerclip.c create mode 100644 nx-X11/programs/Xserver/mi/mizerline.c create mode 100755 nx-X11/programs/Xserver/miext/cw/Imakefile create mode 100644 nx-X11/programs/Xserver/miext/cw/cw.c create mode 100644 nx-X11/programs/Xserver/miext/cw/cw.h create mode 100644 nx-X11/programs/Xserver/miext/cw/cw_ops.c create mode 100644 nx-X11/programs/Xserver/miext/cw/cw_render.c create mode 100755 nx-X11/programs/Xserver/miext/damage/Imakefile create mode 100755 nx-X11/programs/Xserver/miext/damage/damage.c create mode 100755 nx-X11/programs/Xserver/miext/damage/damage.h create mode 100755 nx-X11/programs/Xserver/miext/damage/damagestr.h create mode 100644 nx-X11/programs/Xserver/miext/layer/Imakefile create mode 100644 nx-X11/programs/Xserver/miext/layer/layer.h create mode 100644 nx-X11/programs/Xserver/miext/layer/layergc.c create mode 100644 nx-X11/programs/Xserver/miext/layer/layerinit.c create mode 100644 nx-X11/programs/Xserver/miext/layer/layerpict.c create mode 100644 nx-X11/programs/Xserver/miext/layer/layerstr.h create mode 100644 nx-X11/programs/Xserver/miext/layer/layerwin.c create mode 100644 nx-X11/programs/Xserver/miext/layer/laymodule.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/Imakefile create mode 100644 nx-X11/programs/Xserver/miext/rootless/Imakefile.NX.original create mode 100644 nx-X11/programs/Xserver/miext/rootless/Imakefile.X.original create mode 100644 nx-X11/programs/Xserver/miext/rootless/README.txt create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/Imakefile create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/rlAccel.h create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/rlBlt.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/rlCopy.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/rlFill.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/rlFillRect.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/rlFillSpans.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/rlGlyph.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/accel/rlSolid.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/rootless.h create mode 100644 nx-X11/programs/Xserver/miext/rootless/rootlessCommon.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/rootlessCommon.h create mode 100644 nx-X11/programs/Xserver/miext/rootless/rootlessConfig.h create mode 100644 nx-X11/programs/Xserver/miext/rootless/rootlessGC.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/rootlessScreen.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/rootlessValTree.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/rootlessWindow.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/rootlessWindow.h create mode 100644 nx-X11/programs/Xserver/miext/rootless/safeAlpha/Imakefile create mode 100644 nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlpha.h create mode 100644 nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaPicture.c create mode 100644 nx-X11/programs/Xserver/miext/rootless/safeAlpha/safeAlphaWindow.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/Imakefile create mode 100644 nx-X11/programs/Xserver/miext/shadow/shadow.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shadow.h create mode 100644 nx-X11/programs/Xserver/miext/shadow/shalloc.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shmodule.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shpacked.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shplanar.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shplanar8.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot16pack.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot16pack_180.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot16pack_270.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot16pack_90.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot32pack.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot32pack_180.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot32pack_270.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot32pack_90.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot8pack.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot8pack_180.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot8pack_270.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrot8pack_90.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrotate.c create mode 100644 nx-X11/programs/Xserver/miext/shadow/shrotpack.h create mode 100644 nx-X11/programs/Xserver/os/Imakefile create mode 100644 nx-X11/programs/Xserver/os/Imakefile.NX.original create mode 100644 nx-X11/programs/Xserver/os/Imakefile.X.original create mode 100644 nx-X11/programs/Xserver/os/WaitFor.c create mode 100644 nx-X11/programs/Xserver/os/WaitFor.c.NX.original create mode 100644 nx-X11/programs/Xserver/os/WaitFor.c.X.original create mode 100644 nx-X11/programs/Xserver/os/access.c create mode 100644 nx-X11/programs/Xserver/os/auth.c create mode 100644 nx-X11/programs/Xserver/os/auth.c.NX.original create mode 100644 nx-X11/programs/Xserver/os/auth.c.X.original create mode 100644 nx-X11/programs/Xserver/os/connection.c create mode 100644 nx-X11/programs/Xserver/os/connection.c.NX.original create mode 100644 nx-X11/programs/Xserver/os/connection.c.X.original create mode 100644 nx-X11/programs/Xserver/os/io.c create mode 100644 nx-X11/programs/Xserver/os/k5auth.c create mode 100644 nx-X11/programs/Xserver/os/lbxio.c create mode 100644 nx-X11/programs/Xserver/os/log.c create mode 100644 nx-X11/programs/Xserver/os/log.c.NX.original create mode 100644 nx-X11/programs/Xserver/os/log.c.X.original create mode 100644 nx-X11/programs/Xserver/os/mitauth.c create mode 100644 nx-X11/programs/Xserver/os/oscolor.c create mode 100644 nx-X11/programs/Xserver/os/oscolor.c.NX.original create mode 100644 nx-X11/programs/Xserver/os/oscolor.c.X.original create mode 100644 nx-X11/programs/Xserver/os/osdep.h create mode 100644 nx-X11/programs/Xserver/os/osinit.c create mode 100644 nx-X11/programs/Xserver/os/rpcauth.c create mode 100644 nx-X11/programs/Xserver/os/secauth.c create mode 100644 nx-X11/programs/Xserver/os/utils.c create mode 100644 nx-X11/programs/Xserver/os/utils.c.NX.original create mode 100644 nx-X11/programs/Xserver/os/utils.c.X.original create mode 100644 nx-X11/programs/Xserver/os/xalloc.c create mode 100644 nx-X11/programs/Xserver/os/xdmauth.c create mode 100644 nx-X11/programs/Xserver/os/xdmcp.c create mode 100644 nx-X11/programs/Xserver/os/xdmcp.c.NX.original create mode 100644 nx-X11/programs/Xserver/os/xdmcp.c.X.original create mode 100644 nx-X11/programs/Xserver/os/xprintf.c create mode 100644 nx-X11/programs/Xserver/randr/Imakefile create mode 100644 nx-X11/programs/Xserver/randr/mirandr.c create mode 100644 nx-X11/programs/Xserver/randr/randr.c create mode 100644 nx-X11/programs/Xserver/randr/randrstr.h create mode 100644 nx-X11/programs/Xserver/record/Imakefile create mode 100644 nx-X11/programs/Xserver/record/module/Imakefile create mode 100644 nx-X11/programs/Xserver/record/record.c create mode 100644 nx-X11/programs/Xserver/record/recordmod.c create mode 100644 nx-X11/programs/Xserver/record/set.c create mode 100644 nx-X11/programs/Xserver/record/set.h create mode 100644 nx-X11/programs/Xserver/render/Imakefile create mode 100644 nx-X11/programs/Xserver/render/animcur.c create mode 100644 nx-X11/programs/Xserver/render/filter.c create mode 100644 nx-X11/programs/Xserver/render/glyph.c create mode 100644 nx-X11/programs/Xserver/render/glyphstr.h create mode 100644 nx-X11/programs/Xserver/render/miglyph.c create mode 100644 nx-X11/programs/Xserver/render/miindex.c create mode 100644 nx-X11/programs/Xserver/render/mipict.c create mode 100644 nx-X11/programs/Xserver/render/mipict.h create mode 100644 nx-X11/programs/Xserver/render/mirect.c create mode 100644 nx-X11/programs/Xserver/render/mitrap.c create mode 100644 nx-X11/programs/Xserver/render/mitri.c create mode 100644 nx-X11/programs/Xserver/render/picture.c create mode 100644 nx-X11/programs/Xserver/render/picture.h create mode 100644 nx-X11/programs/Xserver/render/picturestr.h create mode 100644 nx-X11/programs/Xserver/render/render.c create mode 100644 nx-X11/programs/Xserver/render/renderedge.c create mode 100644 nx-X11/programs/Xserver/render/renderedge.h create mode 100755 nx-X11/programs/Xserver/xfixes/Imakefile create mode 100755 nx-X11/programs/Xserver/xfixes/cursor.c create mode 100755 nx-X11/programs/Xserver/xfixes/cursor.c.NX.original create mode 100755 nx-X11/programs/Xserver/xfixes/cursor.c.X.original create mode 100755 nx-X11/programs/Xserver/xfixes/region.c create mode 100755 nx-X11/programs/Xserver/xfixes/saveset.c create mode 100755 nx-X11/programs/Xserver/xfixes/select.c create mode 100755 nx-X11/programs/Xserver/xfixes/select.c.NX.original create mode 100755 nx-X11/programs/Xserver/xfixes/select.c.X.original create mode 100755 nx-X11/programs/Xserver/xfixes/xfixes.c create mode 100755 nx-X11/programs/Xserver/xfixes/xfixes.h create mode 100755 nx-X11/programs/Xserver/xfixes/xfixesint.h create mode 100644 nx-X11/programs/Xserver/xkb/Imakefile create mode 100644 nx-X11/programs/Xserver/xkb/Imakefile.NX.original create mode 100644 nx-X11/programs/Xserver/xkb/Imakefile.X.original create mode 100644 nx-X11/programs/Xserver/xkb/ddxBeep.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxConfig.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxCtrls.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxDevBtn.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxFakeBtn.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxFakeMtn.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxInit.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxKeyClick.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxKillSrv.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxLEDs.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxList.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxLoad.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxLoad.c.NX.original create mode 100644 nx-X11/programs/Xserver/xkb/ddxLoad.c.X.original create mode 100644 nx-X11/programs/Xserver/xkb/ddxPrivate.c create mode 100644 nx-X11/programs/Xserver/xkb/ddxVT.c create mode 100644 nx-X11/programs/Xserver/xkb/xkb.c create mode 100644 nx-X11/programs/Xserver/xkb/xkb.h create mode 100644 nx-X11/programs/Xserver/xkb/xkbAccessX.c create mode 100644 nx-X11/programs/Xserver/xkb/xkbActions.c create mode 100644 nx-X11/programs/Xserver/xkb/xkbDflts.h create mode 100644 nx-X11/programs/Xserver/xkb/xkbDflts.h.NX.original create mode 100644 nx-X11/programs/Xserver/xkb/xkbDflts.h.X.original create mode 100644 nx-X11/programs/Xserver/xkb/xkbEvents.c create mode 100644 nx-X11/programs/Xserver/xkb/xkbInit.c create mode 100644 nx-X11/programs/Xserver/xkb/xkbLEDs.c create mode 100644 nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c create mode 100644 nx-X11/programs/Xserver/xkb/xkbPrOtherEv.c create mode 100644 nx-X11/programs/Xserver/xkb/xkbSwap.c create mode 100644 nx-X11/programs/Xserver/xkb/xkbUtils.c (limited to 'nx-X11/programs/Xserver') 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 + +#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 + + 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 +#endif + +#include "quartzCommon.h" +#include +#include "cr.h" + +// X11 and X11's glx +#undef BOOL +#define BOOL xBOOL +#include "quartz.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 +#endif + +#include "dri.h" +#include "quartz.h" + +#include +#include +#include + +// X11 and X11's glx +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 + +#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 + +#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 + +#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 + * Rickard E. (Rik) Faith + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86.h" +#ifdef XFree86LOADER +#include "xf86_ansic.h" +#else +#include +#include +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#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, ®); + TraverseTree(pWin, DRITreeTraversal, (pointer)(®)); + + if(REGION_NOTEMPTY(pScreen, ®)) { + REGION_TRANSLATE(pScreen, ®, ptOldOrg.x - pWin->drawable.x, + ptOldOrg.y - pWin->drawable.y); + REGION_INTERSECT(pScreen, ®, ®, prgnSrc); + + /* The MoveBuffers interface is not ideal */ + (*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, ®, + pDRIPriv->pDriverInfo->ddxDrawableTableEntry); + } + + REGION_UNINIT(pScreen, ®); + } + + /* 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 + * + */ + +/* 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 + * Rickard E. Faith + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#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 + * + */ + +#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 + * \author Jens Owen + * \author Rickard E. (Rik) Faith + */ + +/* + * 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 + * Jens Owen + * Rickard E. (Rik) Faith + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "xf86.h" +#ifdef XFree86LOADER +#include "xf86_ansic.h" +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#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 + +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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#endif + +#include "glxserver.h" +#include +#include +#include "g_disptab.h" +#include +#include +#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 +#endif + +#include "glxserver.h" +#include "glxutil.h" +#include +#include +#include +#include +#include +#include +#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 +#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 +#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 +#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 +#endif + +#include "glxserver.h" +#include +#include +#include +#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 +#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 +#endif + +#include "glxserver.h" +#include "glxutil.h" +#include "glxfb.h" + +#include + +/* 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 +#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 +#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 +#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 +#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 +#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 +#endif + +#include "glxserver.h" +#include "glxutil.h" +#include "glxpix.h" + +#include + +/* 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 +#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 +#endif + +#ifdef IN_MODULE +#include +#else +#include +#include +#endif + +#include + +#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 +#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 +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 +#include +#include + +/* 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 +#endif + +#include "glxserver.h" +#include +#include +#include +#include +#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 +#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 +#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 +#endif + +#include +#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 +#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; inumVertexes; + 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 +#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 +#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 +#endif + +#include +#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; iformat; + 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 +#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 +#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 +#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 +#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 +#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 +#endif + +#include +#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 +#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 +#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 +#endif + +#include "glxserver.h" +#include "glxutil.h" +#include "g_disptab.h" +#include +#include +#include +#include +#include + +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*) ¤tListIndex); + 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 + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#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 +#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 + +#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 + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#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 + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#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 + +#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 + +#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 + + +#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 + +#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 + * Brian E. Paul + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "xf86glxint.h" +#include "context.h" +#include "xmesaP.h" +#include +#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 +#undef DEBUG +#else +#include +#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 + * Brian Paul + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include "pixmapstr.h" +#include "xf86glx_util.h" +#include +#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 + * Brian Paul + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef _XF86GLX_UTIL_H_ +#define _XF86GLX_UTIL_H_ + +#ifdef __CYGWIN__ +#undef WIN32 +#undef _WIN32 +#endif + +#include +#include +#include +#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 + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#ifndef _XF86GLXINT_H_ +#define _XF86GLXINT_H_ + +#include +#include +#include + +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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +#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 + +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 + + * indirect.c: + Remove __glEvalComputeK. It is no longer used. + + +2005-04-09 Alexander Gottwald + + * 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 + + * 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 + + * 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 from loading + +2005-02-02 Alexander Gottwald + + * 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 + + * glwrap.c: + Functions like glGenTextures and glBindTexture are in OpenGL 1.1 + and can be resolved at linktime. + +2004-11-15 Alexander Gottwald + + * indirect.c: + Bugzilla #1802, http://freedesktop.org/bugzilla/show_bug.cgi?id=1802 + Added mingw (Win32) port + +2004-08-13 Alexander Gottwald + + * 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 + + * 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 + +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 +#endif + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +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 +#endif + +#include +#include +#include +#include +#include + +#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 +#endif + +#include "glwindows.h" +#include +#include + +#include + +#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 + +/* 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 + +/* 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 + +/* 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 + +#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 + + 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 +#endif + +#include "xf86Module.h" + +#include + +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 +#endif + +#ifndef EXTMODULE +#include +#include +#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 /* 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 +#include +#include + +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 +#endif + +#ifndef EXTMODULE +#include +#include +#include +#else +#include "xf86_ansic.h" +#endif +#include +#include +#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 +#include +#include +#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; irealInputProc; + 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; iindex > 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; icur.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; icur.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; icur.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; ihdr.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; ihdr.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 +#endif + +#include +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#include +#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 +#include + +/* 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; icount), 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 +#endif + +#include +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#include +#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 +#include + +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 +#endif + +#include +#include +#include "dixstruct.h" +#include "extnsionst.h" +#include "dix.h" +#define _XEVI_SERVER_ +#include +#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 +#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 + +#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 + +#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 + +#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 +# ::= any | root | +# ::= | = +# :== [ | | ]* +# :== r | w | d +# r read +# w write +# d delete +# :== 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 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 +#endif + +#include +#include +#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 +#include +#define _SECURITY_SERVER +#include +#include + +#define XSERV_t +#include +#include "../os/osdep.h" + +#include + +#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 +#endif + +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include +#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 +#endif + +#include +#include +#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 +#include + +#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 +#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 + * + */ + +/** \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 +#endif + +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#define EXTENSION_PROC_ARGS void * +#include "extnsionst.h" +#include "opaque.h" + +#include "dmxextension.h" +#include + +#define _DMX_SERVER_ +#include + +#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 +#endif + +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "opaque.h" +#define DPMS_SERVER +#include +#include +#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 +#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 +#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 + +#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 +#endif + +#ifdef XFree86LOADER +#include "xf86_ansic.h" + +#include "xf86Module.h" +#include "xf86Opt.h" + +#include + +#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 +#endif + +#ifndef INITARGS +#define INITARGS void +#endif + +#ifdef SHAPE +extern void ShapeExtensionInit(INITARGS); +#define _SHAPE_SERVER_ /* don't want Xlib structures */ +#include +#endif + +#ifdef MULTIBUFFER +extern void MultibufferExtensionInit(INITARGS); +#define _MULTIBUF_SERVER_ /* don't want Xlib structures */ +#include +#endif + +#ifdef MITMISC +extern void MITMiscExtensionInit(INITARGS); +#define _MITMISC_SERVER_ +#include +#endif + +#ifdef XTEST +extern void XTestExtensionInit(INITARGS); +#define _XTEST_SERVER_ +#include +#include +#endif + +#if 1 +extern void XTestExtension1Init(INITARGS); +#endif + +#ifdef BIGREQS +extern void BigReqExtensionInit(INITARGS); +#include +#endif + +#ifdef XSYNC +extern void SyncExtensionInit(INITARGS); +#define _SYNC_SERVER +#include +#include +#endif + +#ifdef SCREENSAVER +extern void ScreenSaverExtensionInit (INITARGS); +#include +#endif + +#ifdef XCMISC +extern void XCMiscExtensionInit(INITARGS); +#include +#endif + +#ifdef XF86VIDMODE +extern void XFree86VidModeExtensionInit(INITARGS); +#define _XF86VIDMODE_SERVER_ +#include +#endif + +#ifdef XF86MISC +extern void XFree86MiscExtensionInit(INITARGS); +#define _XF86MISC_SERVER_ +#define _XF86MISC_SAVER_COMPAT_ +#include +#endif + +#ifdef XFreeXDGA +extern void XFree86DGAExtensionInit(INITARGS); +extern void XFree86DGARegister(INITARGS); +#define _XF86DGA_SERVER_ +#include +#endif + +#ifdef DPMSExtension +extern void DPMSExtensionInit(INITARGS); +#include +#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 +#endif + +#ifdef EVI +extern void EVIExtensionInit(INITARGS); +#define _XEVI_SERVER_ +#include +#endif + +#ifdef XV +extern void XvExtensionInit(INITARGS); +extern void XvMCExtensionInit(INITARGS); +extern void XvRegister(INITARGS); +#include +#include +#endif + +#ifdef RES +extern void ResExtensionInit(INITARGS); +#include +#endif + +#ifdef SHM +extern void ShmExtensionInit(INITARGS); +#include +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 . + * 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 +#endif + +#include +#include +#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 + +#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 +#endif + +#include +#include +#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 + +#ifdef EXTMODULE +#include "xf86_ansic.h" +#else +#include +#if !defined(WIN32) && !defined(Lynx) +#include +#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, ®ion, &box, 1); + MultibufferExpose(pMultibuffer, ®ion); + REGION_UNINIT(pScreen, ®ion); + } + 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 +#endif + +#include +#include +#include +#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 + +#define _MULTIBUF_SERVER_ /* don't want Xlib structures */ +#define _MULTIBUF_BUFFER_ +#include + +/* +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, ®, &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, ®, ®, &pBuffer->clipList); + if (pBuffer->backgroundState != None) + (*pScreen->PaintWindowBackground)(pBuffer, ®, PW_BACKGROUND); + if (generateExposures) + MultibufferExpose(pMBBuffer, ®); +#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, ®, pBSReg); + else if (pBuffer->backgroundState != None) + (*pScreen->PaintWindowBackground)(pBuffer, ®, PW_BACKGROUND); +#endif + REGION_UNINIT(pScreen, ®); + 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; inumMultibuffer; 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; idisplayedMultibuffer; 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; inumMultibuffer; 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 +#endif + +#include +#include +#include +#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 + +#define _MULTIBUF_SERVER_ /* don't want Xlib structures */ +#define _MULTIBUF_PIXMAP_ +#include + + +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, ®ion, &box, 1); + + if (pMBBuffer->number == pMBBuffer->pMBWindow->displayedMultibuffer) + pDrawable = (DrawablePtr) pWin; + else + pDrawable = pMBBuffer->pDrawable; + + MultibufferPaintBackgroundRegion(pWin, pDrawable, ®ion); + + if (exposures) + MultibufferExpose(pMBBuffer, ®ion); + + REGION_UNINIT(pScreen, ®ion); +} + +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 +#endif + +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "extnsionst.h" +#define _MITMISC_SERVER_ +#include +#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 +#endif + +#ifdef HAVE_DMX_CONFIG_H +#include +#endif + +#define NEED_REPLIES +#include +#include +#include +#include +#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 +#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 +#endif + +#ifndef _PANORAMIX_H_ +#define _PANORAMIX_H_ + +#include +#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 +#endif + +#include +#include +#include +#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 +#include +#endif +#include "panoramiX.h" +#include +#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 */ + +/* $XFree86: xc/programs/Xserver/Xext/panoramiXprocs.c,v 3.36tsi Exp $ */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#define NEED_REPLIES +#define NEED_EVENTS +#include +#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 +#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 +#endif + +#include +#include +#include "dixstruct.h" +#include "extnsionst.h" +#include "dix.h" +#define _XEVI_SERVER_ +#include +#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 +#endif + +#include +#include +#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 +#include "gcstruct.h" +#include "cursorstr.h" +#include "colormapst.h" +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" +#endif + + +#ifdef IN_MODULE +#include +#else +#include +#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 +#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 +#include +#include +#ifdef LBX +#define _XLBX_SERVER_ +#include +extern unsigned char LbxReqCode; +#endif +#ifdef XAPPGROUP +#include +#endif +#include /* for file reading operations */ +#include /* for XA_STRING */ + +#ifdef NXAGENT_SERVER + +#include +#include +#include +#include + +#endif + +#ifndef DEFAULTPOLICYFILE +# define DEFAULTPOLICYFILE NULL +#endif + +#ifdef NXAGENT_SERVER + +#define NX_ALTERNATIVEPOLICYFILE "/usr/lib/xserver/SecurityPolicy" + +#endif + +#if defined(WIN32) || defined(__CYGWIN__) +#include +#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; iauthId == 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 +#include +#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 +#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 +#include +#include +#ifdef LBX +#define _XLBX_SERVER_ +#include +extern unsigned char LbxReqCode; +#endif +#ifdef XAPPGROUP +#include +#endif +#include /* for file reading operations */ +#include /* for XA_STRING */ + +#ifdef NXAGENT_SERVER + +#include +#include +#include +#include + +#endif + +#ifndef DEFAULTPOLICYFILE +# define DEFAULTPOLICYFILE NULL +#endif + +#ifdef NXAGENT_SERVER + +#define NX_ALTERNATIVEPOLICYFILE "/usr/lib/xserver/SecurityPolicy" + +#endif + +#if defined(WIN32) || defined(__CYGWIN__) +#include +#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; iauthId == 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 +#include +#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 +#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 +#include +#include +#ifdef LBX +#define _XLBX_SERVER_ +#include +extern unsigned char LbxReqCode; +#endif +#ifdef XAPPGROUP +#include +#endif +#include /* for file reading operations */ +#include /* for XA_STRING */ + +#ifndef DEFAULTPOLICYFILE +# define DEFAULTPOLICYFILE NULL +#endif +#if defined(WIN32) || defined(__CYGWIN__) +#include +#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; iauthId == 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 +#include +#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 +#endif + +#include +#include +#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 +#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 +#endif + +#include +#ifndef Lynx +#include +#include +#else +#include +#include +#endif +#include +#include +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#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 +#include +#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 + +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; ipScreen->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; ipScreen->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 +#endif + +#include "sleepuntil.h" +#include +#include +#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 +#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 +#endif + +#include +#include +#include +#include "misc.h" +#include "os.h" +#include "extnsionst.h" +#include "dixstruct.h" +#include "resource.h" +#include "opaque.h" +#define _SYNC_SERVER +#include +#include + +#ifdef EXTMODULE +#include "xf86_ansic.h" +#else +#include +#if !defined(WIN32) && !defined(Lynx) +#include +#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 +#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 +#endif + +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "swaprep.h" +#include +#include "modinit.h" + +#if HAVE_STDINT_H +#include +#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 +#endif + +#include +#include +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XEVIE_SERVER_ +#include +#include +#include "input.h" +#include "inputstr.h" +#include "windowstr.h" +#include "cursorstr.h" +#include + +#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; ixkbInfo = 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 +#endif + +#include +#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 . */ +#include +#endif +#ifdef SVR4 +#include +#endif +#if defined(ISC) || defined(__CYGWIN__) || defined(__SCO__) +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#endif + +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "gcstruct.h" +#include "dixfontstr.h" +#include "extnsionst.h" + +#define _XF86BIGFONT_SERVER_ +#include + +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 + +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 +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#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 +#include +#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 +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#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 +#include +#include "swaprep.h" +#include "dgaproc.h" +#include "xf86dgaext.h" + +#ifdef EXTMODULE +#include "xf86_ansic.h" +#else +#include +#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 +#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 +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#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 +#include "swaprep.h" +#include "xf86.h" +#include +#include "xf86miscproc.h" + +#if 0 +#include +#include "../os/osdep.h" +#include +#ifndef USL +#ifndef Lynx +#include +#else +#include +#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 +#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 +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86VIDMODE_SERVER_ +#include +#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 +#endif + +#include +#include +#define NEED_EVENTS +#include +#undef NEED_EVENTS +#include "misc.h" +#include "windowstr.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "extnsionst.h" +#include "dixstruct.h" +#include +#include +#include +#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 +#endif + +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "swaprep.h" +#include +#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 +#endif + +#include +#define NEED_EVENTS +#include +#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 +#include +#ifdef XINPUT +#include +#include +#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 = ; +#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 +#endif + +#include +#include +#include +#include +#include +#include "misc.h" +#include "dixstruct.h" +#define XTestSERVER_SIDE +#include + +#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(¤t_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 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(¤t_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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include +#include +#include +#include "misc.h" +#include "os.h" +#include "gcstruct.h" +#include "extnsionst.h" +#include "dixstruct.h" +#include "opaque.h" +#define XTestSERVER_SIDE +#include +#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 +#endif + +#include +#include +#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 +#include +#include "xvdix.h" +#ifdef MITSHM +#define _XSHM_SERVER_ +#include +#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 + +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 +#endif + +#include +#include +#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 +#include +#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 +#endif + +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "resource.h" +#include "scrnintstr.h" +#include "extnsionst.h" +#include "servermd.h" +#include +#include "xvdix.h" +#include +#include +#include +#include "xvmcext.h" + +#ifdef HAS_XVMCSHM +#ifndef Lynx +#include +#include +#include +#else +#include +#include +#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 +#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 +#endif + +#include +#include "misc.h" +#include "scrnintstr.h" +#include "gc.h" +#include +#include +#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 +#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 + + 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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include + +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include /* 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; inum_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; inum_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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include /* 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; inum_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; inum_keysyms; i++) + { + for (j=0; jctrl.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; inum_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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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; itraceSize; 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" +#include +#include +#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; icount; 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; imode == 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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; iid); + 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ +#include +#include +#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; ifirstChild; + 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include +#include +#include +#include +#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; itype == 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; imask[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; iinputEvents[i] |= others->mask[i]; + } + for (i=0; ideliverableEvents[i] = inputMasks->inputEvents[i]; + for (tmp = pChild->parent; tmp; tmp=tmp->parent) + if (wOtherInputMasks(tmp)) + for (i=0; ideliverableEvents[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; idontPropagateMask[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; idontPropagateMask[i]; + if (!ignoreSelectedEvents) + for (i=0; iinputEvents[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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include +#include +#include "inputstr.h" +#include "gcstruct.h" /* pointer for extnsionst.h*/ +#include "extnsionst.h" /* extension entry */ +#include +#include + +#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= 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; inext) + { + 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= 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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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; inumAxes; i++,a++) + *iptr++ = a->resolution; + for (i=0,a=v->axes; inumAxes; i++,a++) + *iptr++ = a->min_resolution; + for (i=0,a=v->axes; inumAxes; 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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; ictrl.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; ictrl.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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "windowstr.h" /* focus struct */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include /* 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structs */ +#include +#include +#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; idontPropagateMask[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; idontPropagateMask[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; jsequenceNumber, 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include +#include +#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; imask[i], i, + &rep.all_clients_count, COUNT); + + for (others = pOthers->inputClients; others; others=others->next) + if (SameClient(others, client)) + { + for (i=0; imask[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; imask[i], i, NULL, CREATE); + + for (others = pOthers->inputClients; others; others=others->next) + for (i=0; imask[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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#include +#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; ievent_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> 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; jsequenceNumber, 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#include +#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; ievent_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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#include +#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; ievent_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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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; isequenceNumber, 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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; jmin_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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#include +#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; inumAxes; 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#include +#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; icount; 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* Window */ +#include +#include +#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; inum_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; icount; 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "windowstr.h" /* focus struct */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include + +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include +#include +#include "inputstr.h" +#include +#include +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include /* for inputstr.h */ +#include /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include +#include +#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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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.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 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00051.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00052.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00053.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00054.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00055.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00056.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00057.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00058.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00059.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00060.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00061.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00062.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00063.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00064.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00065.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00066.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00067.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00068.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00069.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00070.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00071.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00072.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00073.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00074.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00075.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00076.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00077.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00079.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00080.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00081.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00082.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00083.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00084.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00085.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00086.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00087.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00088.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00089.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00090.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00091.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00092.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00093.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/9nb00094.pmf 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 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/lpr0ye1a.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00051.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00052.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00053.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00054.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00055.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00056.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00057.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00058.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00059.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00060.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00061.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00062.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00063.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00064.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00065.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00066.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00067.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00068.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00069.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00070.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00071.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00072.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00073.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00074.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00075.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00076.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00077.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00079.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00080.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00081.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00082.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00083.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00084.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00085.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00086.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00087.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00088.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00089.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00090.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00091.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00092.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00093.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/9nb00094.pmf 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 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/lpr0ye1a.pmf 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.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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Book.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-BookOblique.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Demi.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-DemiOblique.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Bold.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-BoldOblique.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Oblique.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Bold.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-BoldOblique.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Oblique.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Book.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-BookOblique.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Demi.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-DemiOblique.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Demi.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-DemiItalic.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Light.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-LightItalic.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Symbol.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Bold.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-BoldItalic.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Italic.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Roman.pmf 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 Binary files /dev/null and b/nx-X11/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/ZapfDingbats.pmf 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.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 ] [: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 menu and selecting . 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 , which +will start a dtpdm capable of modifying additional print options. +Finally, the user should select . + + + +$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 +#endif + +#include + +#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 +#endif + +#ifndef _Xp_AttrValid_h +#define _Xp_AttrValid_h + +#include +#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 +#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 + +#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 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __hpux +#include +#endif + +#include +#define NEED_EVENTS 1 +#include +#include + +#include "screenint.h" +#include "input.h" +#include "cursor.h" +#include "misc.h" +#include "windowstr.h" +#include "inputstr.h" + +#include "gcstruct.h" +#include +#include "errno.h" + +typedef char *XPointer; +#define HAVE_XPointer 1 + +#define Status int +#include + +#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 +#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; /* "{ } " */ + } + 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; /* "{ } " */ + } + /* + * 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 +#endif + +#ifndef _Xp_Oid_h +#define _Xp_Oid_h + +#include + +/* + * 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 */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#if defined(linux) && defined(__STRICT_ANSI__) +#undef __STRICT_ANSI__ +#endif + +#include /* for unistd.h and string.h */ +#include +#include +#include +#include "misc.h" +#include "dixstruct.h" + +#include + +#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 +#endif + +#include +#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 @@ +Xprt

Name

Xprt — Print server for X Version 11

Synopsis

Xprt [-ac] [-audit level] [-pn] [-fp fontpath] [-XpFile file] [-XpSpoolerType spoolername] [:display]

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.

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

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

USAGE

+ Although Xprt may be invoked from the command line, it is + preferable to run it as a daemon via the init script + /etc/init.d/xprint (where this script exists). +

Client programs such as mozilla will require environment + variable ${XPSERVERLIST} to be set, identifying the + "display" on which Xprt is running. This variable may be set + for all users via /etc/profile (or similar), using + /etc/init.d/xprint get_xpserverlist: +

export XPSERVERLIST=`/etc/init.d/xprint get_xpserverlist`

OPTIONS

Many of Xprt's command line options are shared in common + with the usual X servers (see Xserver(1x)). + Commonly used options include:

:display

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 /etc/init.d/xprint is used + to invoke Xprt, it may be configured to automatically assign an available + display number.

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

-audit level

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.

-fp fontpath

sets the search path for fonts. This path is a comma + separated list of directories which Xprt searches for + font databases.

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

-XpFile file

Sets an altername Xprinters file (see section FILES).

-XpSpoolerType spoolername

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

Xprt -h

. +

ENVIRONMENT

+ The following environment variables are recognized by the X print server + (environment variables recognized by Xprint clients are described in + Xprint(7)): + +

${XPCONFIGDIR}

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 + /usr/X11R6/lib/X11/xserver/, + /usr/lib/X11/xserver/, + /usr/share/Xprint/xserver/ or + /usr/openwin/server/etc/XpConfig, depending on the + system, and may be configured in /etc/init.d/xprint.

${LANG}

+ This environment variable selects the locale settings used by the Xprint server. + Xprt allows language-specific settings (stored in ${XPCONFIGDIR}/${LANG}/print/) + which will override the default settings (stored in ${XPCONFIGDIR}/C/print/). + If ${LANG} is not set "C" is assumed. +

FILES

${XPCONFIGDIR}/${LANG}/print/Xprinters, ${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}/${LANG}/print/attributes/printer, ${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}/${LANG}/print/attributes/document, ${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}/${LANG}/print/attributes/job, ${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/PSdefault/model-config, ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/fonts.dir, ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00051.pmf, ${XPCONFIGDIR}/C/print/models/PSdefault/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/pdf, ${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. +

SEE ALSO

Xprint(7), X11(7), xplsprinters(1x), xprehashprinterlist(1x), xphelloworld(1x), xpxmhelloworld(1x), xpawhelloworld(1x), xpxthelloworld(1x), xpsimplehelloworld(1x), Xserver(1x), libXp(3x), libXprintUtils(3x), libXprintAppUtils(3x), XmPrintShell(3x), XawPrintShell(3x), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html), Xprint main site (http://xprint.mozdev.org/)

AUTHORS

+ This manual page was written by + Drew Parsons and + Roland Mainz , + with some help from the man page at + http://www.sins.com.au/unix/manpages/Xprt.html and the XFree86 + man page for Xserver(1). +

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 and +Roland Mainz , +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 @@ + + + + + + + Xprt + __appmansuffix__ + + + Xprt + + Print server for X Version 11 + + + + Xprt + + + + + + + + + + + + + + + + + + + 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. + + 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. + + + 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. + + + + + USAGE + + + Although Xprt may be invoked from the command line, it is + preferable to run it as a daemon via the init script + /etc/init.d/xprint (where this script exists). + + + Client programs such as mozilla will require environment + variable ${XPSERVERLIST} to be set, identifying the + "display" on which Xprt is running. This variable may be set + for all users via /etc/profile (or similar), using + /etc/init.d/xprint get_xpserverlist: + + export XPSERVERLIST=`/etc/init.d/xprint get_xpserverlist` + + + + + + OPTIONS + + Many of Xprt's command line options are shared in common + with the usual X servers (see Xserver__appmansuffix__). + Commonly used options include: + + + + + + + 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 /etc/init.d/xprint is used + to invoke Xprt, it may be configured to automatically assign an available + display number. + + + + + + + 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. + + + + + + + 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. + + + + + + + sets the search path for fonts. This path is a comma + separated list of directories which Xprt searches for + font databases. + + + + + + + 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. + + + + + + + + Sets an altername Xprinters file (see section FILES). + + + + + + + + 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 + Xprt -h. + + + + + + + + ENVIRONMENT + + The following environment variables are recognized by the X print server + (environment variables recognized by Xprint clients are described in + Xprint__miscmansuffix__): + + + + ${XPCONFIGDIR} + + 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 + /usr/X11R6/lib/X11/xserver/, + /usr/lib/X11/xserver/, + /usr/share/Xprint/xserver/ or + /usr/openwin/server/etc/XpConfig, depending on the + system, and may be configured in /etc/init.d/xprint. + + + + + ${LANG} + + + This environment variable selects the locale settings used by the Xprint server. + Xprt allows language-specific settings (stored in ${XPCONFIGDIR}/${LANG}/print/) + which will override the default settings (stored in ${XPCONFIGDIR}/C/print/). + If ${LANG} is not set "C" is assumed. + + + + + + + + + FILES + + + + ${XPCONFIGDIR}/${LANG}/print/Xprinters + ${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 lpstat1 or other commands + should be used to automatically supplement the list of + printers. + + + + + + ${XPCONFIGDIR}/${LANG}/print/attributes/printer + ${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 lpstat1 in the Xprinters + file, setting up defaults in `printer' becomes all the + more important. + + + + + + ${XPCONFIGDIR}/${LANG}/print/attributes/document + ${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}/${LANG}/print/attributes/job + ${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/PSdefault/model-config + ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/fonts.dir + ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00051.pmf + ${XPCONFIGDIR}/C/print/models/PSdefault/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/pdf + ${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. + + + + + + + + + SEE ALSO + + + + + + + Xprint__miscmansuffix__ + X11__miscmansuffix__ + xplsprinters__appmansuffix__ + xprehashprinterlist__appmansuffix__ + xphelloworld__appmansuffix__ + xpxmhelloworld__appmansuffix__ + xpawhelloworld__appmansuffix__ + xpxthelloworld__appmansuffix__ + xpsimplehelloworld__appmansuffix__ + Xserver__appmansuffix__ + + + libXp__libmansuffix__ + libXprintUtils__libmansuffix__ + libXprintAppUtils__libmansuffix__ + XmPrintShell__libmansuffix__ + XawPrintShell__libmansuffix__ + Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html) + Xprint main site (http://xprint.mozdev.org/) + + + + + + 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 Xserver1. + + + + + + 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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if (defined(sun) && defined(SVR4)) || defined(__SCO__) || defined(__UNIXWARE__) +#include +#endif +#include "scrnintstr.h" + +#include + +#include "attributes.h" + +#include +#include + +#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 + +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 ./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 +#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 +#endif + +#include +#include +#include +#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 +#include +#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 +### +### 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 . +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 "${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 +# 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 +# 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 +#endif + +#include +#include +#include +#include +#include +#include + +#include +#include "dixstruct.h" +#include "screenint.h" +#include "misc.h" +#include "scrnintstr.h" +#include + +#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 + +#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 +#endif + +#ifndef _PCL_H_ +#define _PCL_H_ + +#include +#include "scrnintstr.h" + +#include "PclDef.h" +#include "Pclmap.h" +#include "PclSFonts.h" + +#include +#include + +#include "regionstr.h" +#include +#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 +#include +#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 +#endif + +#include +#include +#include + +#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 +#endif + +#include +#include +#include +#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 +#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 +#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 +#endif + +#include +#include +#include +#include +#include +#include +#include + +#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>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 +#endif + +#include + +#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 +#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 +#endif + +#include "regionstr.h" +#include +#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 +#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 +#endif + +#include +#include +#include +#include + +#include "Pcl.h" + +#include "cfb.h" +#include /* 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 +#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 +#endif + +#include +#include +#include +#include +#include /* 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 +#include + +/* 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 +#endif + +#include + +#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 +#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 +#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 +#endif + +#include +#include +#include +#include +#include +#include +#include + +#define NEED_EVENTS +#include +#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 +#endif + +#include +#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; iindex[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; iheight; 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; jwidth; 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 +#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 +#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 +#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 + +#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; iindex[*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; ifid ) { + 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; imetrics.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; ifirstRow <= 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; ifirstRow <= 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; ifont, (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; ifontname); + 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; inprops; 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; iheight; i++) { + pg = pglyph + nbyGlyphWidth * i; + for (j=0; jinfo; + props = pfi->props; + fontname = (char *) NULL; + for (i=0; inprops; 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; inprops; 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 +#endif + +#include +#include +#include +#include + +#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 +#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 + +#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 +#endif + +#ifndef _PS_H_ +#define _PS_H_ + +#include + +#ifdef abs +#undef abs /* this is because of a non-Spec1170ness in misc.h */ +#endif +#include +#include "scrnintstr.h" +#include "dix.h" + +#include "PsDef.h" +#include "psout.h" + +#include +#include + +#include "regionstr.h" +#include +#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 +#include +#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 +#endif + +#include + +#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 ; itype==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 +#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 ; rbgPixel), + PsGetPixelColor(cMap, pGC->fgPixel), + x, y, w, h, sw, sh, 1); + for( r=0 ; r>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 ; rbgPixel), + PsGetPixelColor(cMap, pGC->fgPixel), + x, y, w, h, sw, sh, 1); + for( r=0 ; r>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 +#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 +#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 +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" +#include +#include + +#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 +#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 ; ired[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 +#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 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 +#endif + +#include +#include +#include + +#include "regionstr.h" +#include +#include "dixfontstr.h" +#include "scrnintstr.h" +#include +#include +#include + +#include "Ps.h" + +#include +#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 +#endif + +#include "regionstr.h" +#include +#include "dixfontstr.h" +#include "scrnintstr.h" +#include +#include +#include + +#include "Ps.h" + +#include +#include +#include + +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 ; iinfo.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 ; iinfo.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 ; iinfo.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 ; ifpe->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:""); +#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) :("")), + ((rec->adobe_ps_name) ?(rec->adobe_ps_name):("")), + ((rec->download_ps_name)?(rec->download_ps_name):(""))); +#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):(""))); +#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 +#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 ; inOutterClips ; 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 ; inRects ; 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 ; inRects ; 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 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 +#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 +#endif + +#include +#include +#include +#include +#include +#include + +#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 +#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 ; itype==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 +#endif + +#include /* for SIGCLD on pre-POSIX systems */ +#include +#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 + +*/ +/* 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 ; idash[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 +#endif + +#include + +#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 +#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 ; inelms ; 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->nelmsnext = (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 ; inelms ; 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 ; ic.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 ; ic.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 ; ic.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 ; ic.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 ; ic.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 ; ic.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 ; ic.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 ; inelms ; 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 ; inelms ; 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 ; inelms ; 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 ; kc.polyPts.pPoints[k].x; + elms[*nElms].c.points[k].y = elm->c.polyPts.pPoints[k].y; + } + *nElms += 1; + break; + case PolyFillRectCmd: + for( k=0 ; kc.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 ; kc.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 +#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 ; itype==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 ; itype==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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#define NEED_EVENTS +#include +#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 +#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 +#endif + +#include "Ps.h" +#include "gcstruct.h" +#include "windowstr.h" +#include +#include +#include + +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 ; ifont; + 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; imetrics.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 +#endif + +#include +#include +#include + +#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 +#endif + +#include +#include +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" +#ifdef XP_USE_FREETYPE +#include +#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 + * + * Cs - Coordinate setup (for origin upper left) + * + * Cs + * + * P - Draw a point + * + * P + * + * R - Add rectangle to path + * + * R + * + * Ac - Add arc to path + * + * Ac + * + * An - Add arc to path (counterclockwise) + * + * An + * + * Tf - Set font + * + * Tf + * + * Tfm - Set font with matrix + * + * Tfm + * + * T - Draw text + * + * T + * + * Tb - Draw text with background color + * + * Tb + * + * Im1 - Image 1 bit monochrome imagemask + * + * Im1 + * + * Im24 - Image 24 bit RGB color + * + * Im24 + * + * Im1t - Image 1 bit monochrome imagemask (in tile) + * + * Im1t + * + * Im24t - Image 24 bit RGB color (in tile) + * + * 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=' ' && 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=' ' && 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 ; inOutterClips ; i++ ) + { + if( memcmp(&clpinf->outterClips[i], &self->Clip.outterClips[i], + sizeof(PsRectRec))!=0 ) break; + } + if( inOutterClips ) changed = 1; + else + { + for( i=0 ; inRects ; 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 ; inElms ; 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 ; kelms[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 ; iClip.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 ; iClip.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 ; iClip.nElms ; i++,elm++ ) + { + switch(elm->type) + { + case PSOUT_POINTS: + for( k=0 ; knPoints ; 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 ; iDashes[i] ) break; } + if( iNDashes && 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 ; iDashes[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 ; iFillRule==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 ; iLineBClr != 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 ; iXOff; + 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 ; iRevImage ) 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 ; iNPatterns ; i++ ) + { if( self->Patterns[i].tag==tag && self->Patterns[i].type==type ) break; } + if( iNPatterns ) 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 ; iNPatterns ; 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>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 +#endif + +#ifndef _psout_ +#define _psout_ + +#include + +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 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 +#endif + +#include +#include +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" + +#include +#include FT_FREETYPE_H +#include FT_TYPE1_TABLES_H + +#include +#include +#include +#include +#include +#include +#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 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 +#endif + +#include +#include +#include +#include + +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" + +#include +#include FT_FREETYPE_H + +#include +#include +#include +#include +#include +#include +#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 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 +#endif + +#include +#include +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" + +#include +#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 +#include +#include +#include +#include +#include +#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 +#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 + +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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* for SIGCLD on pre-POSIX systems */ +#define NEED_EVENTS +#include +#undef NEED_EVENTS +#include +#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 +#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 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; idrawable; + 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 + +/* 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 +#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 +#include +#include "attributes.h" + +#include + +#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 +#endif + +#include +#include +#include "misc.h" +#include "dixstruct.h" +#include "scrnintstr.h" +#include "screenint.h" +#include +#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 +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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __hpux +#include +#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 +#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 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 , ignore +the text after the /; it is used to distinguish between instances of + in the next section. +.PP +.nf + ::= * + + ::= '\en' + + ::= | | | + + ::= # * '\en' + + ::= '\en' + + ::= sitepolicy '\en' + + ::= property '\en' + + ::= + + ::= any | root | + + ::= | + + ::= = + + ::= [ | | ]* + + ::= r | w | d + + ::= a | i | e + + ::= | | + + ::= " * " + + ::= ' * ' + + ::= + + + ::= [ ' ' | '\et' ]* + +Character sets: + + ::= any character except '\en' + ::= any character except " + ::= any character except ' + ::= any character except those in +.fi +.PP +The semantics associated with the above syntax are as follows. +.PP +, the first line in the file, specifies the file format +version. If the server does not recognize the version , it +ignores the rest of the file. The version string for the file format +described here is "version-1" . +.PP +Once past the , lines that do not match the above syntax +are ignored. +.PP + lines are ignored. +.PP + lines are currently ignored. They are intended to +specify the site policies used by the XC-QUERY-SECURITY-1 +authorization method. +.PP + lines specify how the server should react to untrusted +client requests that affect the X Window property named . +The rest of this section describes the interpretation of an +. +.PP +For an to apply to a given instance of , + must be on a window that is in the set of windows +specified by . If is any, the rule applies to + on any window. If is root, the rule applies to + only on root windows. +.PP +If is , the following apply. If is a , the rule applies when the window also +has that , regardless of its value. If is a , must also have +the value specified by . 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 , the +rule applies. +.PP +The definition of string matching is simple case-sensitive string +comparison with one elaboration: the occurrence of the character '*' in + is a wildcard meaning "any string." A 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 lines for a given . +The rules are tested in the order that they appear in the file. The +first rule that applies is used. +.PP + specify operations that untrusted clients may attempt, and +the actions that the server should take in response to those operations. +.PP + 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 + 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 applies to all s that follow it, until the next + 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 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 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 + +#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 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 and +-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 +#endif + +#include +#include + +#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 +#endif + +#include +#include +#include +#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 +#endif + +#include +#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 +#endif + +#include +#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 +#endif + +#include "afb.h" +#include +#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 +#endif + +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#include +#include "afb.h" +#include +#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 +#endif + +#include +#include +#include +#include "afb.h" +#include "dixfontstr.h" +#include +#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 +#endif + +#include +#include + +#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 +#endif + +#include + +#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 +#endif + +#include +#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 +#endif + +#include +#include +#include +#include "afb.h" +#include +#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 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 +#endif + +#include + +#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 +#endif + +#include +#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 +#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 +#endif + +#include +#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. afbUnnaturalFS 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 +#endif + +#include + +#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 +#endif + +#include +#include +#include +#include "afb.h" +#include +#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 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 +#endif + +#include + +#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 +#endif + +#include + +#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 +#endif + +#include +#include +#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 +#endif + +#include +#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 +#endif + +#include +#include /* for xColorItem */ +#include +#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 +#endif + +#include +#include + +#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 +#endif + +#include +#include +#include +#include "afb.h" +#include +#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 +#endif + +#include + +#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 +#endif + +#include +#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 +#endif + +#include +#include +#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 + +#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 +#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 +#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 +#endif + +#if PSZ == 8 + +#include +#include +#include +#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 +#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<= 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 +#endif + +#include + +#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 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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#include +#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 +#endif + +#include +#include +#include +#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 +#endif + +#include +#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 +#endif + +#include +#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 +#endif + +#include "cfb.h" +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#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 +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 +#endif + +#include +#include +#include +#include "cfb.h" +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#include +#include "cfb.h" +#include +#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 +#endif + +#include + +#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 +#endif + +#include +#include +#include +#include "mi.h" +#include "cfb.h" +#include +#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 +#endif + +#include +#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 +#endif + +#include + +#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 +#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 +#endif + +#include +#include +#include +#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 +#include +#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 +#endif + +#include +#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>= 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; idrawable.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 +#endif + +#include + +#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 +#endif + +#include + +#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 +#endif + +#include +#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 +#endif + +#if PSZ == 8 + +#include +#include +#include +#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 +#endif + +#if PSZ == 8 + +#include +#include +#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 +#endif + +#include +#include +#include +#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 +#endif + +#ifndef GXcopy +#include +#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; \ + (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 +#endif + +#include +#include +#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 +#endif + +#include +#include +#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 + +/* 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 +#endif + +#include +#include +#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 +#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 +#endif + +#if PSZ == 8 + +#include +#include +#include +#include "cfb.h" +#include +#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 +#endif + +#include +#include +#include +#include "cfb.h" +#include +#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 +#endif + +#include +#include +#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])); \ + (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 +#endif + +#include +#include +#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 +#endif + +#include +#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 +#endif + +#include +#include +#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 +#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 +#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 +#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 + + 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 +#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 +#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 +#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 +#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 +#include + +/* + * 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 +#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 + + 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 +#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 +#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 +#endif + +#ifndef _DAMAGEEXTINT_H_ +#define _DAMAGEEXTINT_H_ + +#define NEED_EVENTS +#include +#include +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include +#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 + +#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 +#endif + +#include +#include +#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 +#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 +#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 +#endif + +#include +#include +#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 +#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 +#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 +#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 + +#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 +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 + +#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 +#endif + +#include +#include +#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 +#endif + +#include +#define NEED_EVENTS +#include +#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<>> + + */ + + 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 +#endif + +#include +#include +#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 +#endif + +#include +#include "misc.h" +#include "resource.h" +#define NEED_EVENTS +#define NEED_REPLIES +#include +#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 +#endif +#ifdef XCSECURITY +#define _SECURITY_SERVER +#include +#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; iaxisVal[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; ictrl.symbols_supported+i) = *symbols++; + for (i=0; ictrl.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; iclientState == 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 +#endif + +#ifdef PANORAMIX_DEBUG +#include +int ProcInitialConnection(); +#endif + +#include "windowstr.h" +#include +#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 +#endif +#ifdef XAPPGROUP +#include +#endif +#ifdef XKB +#define XKB_IN_SERVER +#include "inputstr.h" +#include +#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; ilastDrawableID == 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; ipScreen->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; icloseDownMode = 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; icloseDownMode == 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; icurrentInputMask = 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 + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright 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 +#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 +#endif + +#include +#include +#include +#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 +#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 +#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 +#endif + +#include +#include +#include +#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 +#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 +#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 +#endif + +#include +#include +#include +#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 +#endif + +#ifdef PANORAMIX +#include "panoramiX.h" +#endif + +#ifdef LBX +#include "lbxserve.h" +#endif + +#ifdef XF86BIGFONT +#define _XF86BIGFONT_SERVER_ +#include +#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 +#endif + +#include +#include +#include "misc.h" +#include "windowstr.h" +#include "dixstruct.h" +#include "pixmapstr.h" +#include "scrnintstr.h" +#define XK_LATIN1 +#include +#ifdef XCSECURITY +#define _SECURITY_SERVER +#include +#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 +#endif + +#include +#include "misc.h" +#include "resource.h" +#define NEED_EVENTS +#define NEED_REPLIES +#include +#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 +extern Bool XkbFilterEvents(ClientPtr, int, xEvent *); +#endif + +#ifdef XCSECURITY +#define _SECURITY_SERVER +#include +#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 +#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 ButtonMotionMasks are equal + * to the corresponding ButtonMasks 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; iparent, NullWindow, mode, + NotifyNonlinearVirtual, FALSE); + } + /* Notify all the roots */ +#ifdef PANORAMIX + if ( !noPanoramiXExtension ) + FocusEvent(dev, FocusIn, mode, in, WindowTable[0]); + else +#endif + for (i=0; iparent != 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 +#endif + +#include +#define NEED_EVENTS +#define NEED_REPLIES +#include +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "gcstruct.h" +#include "scrnintstr.h" +#include "dispatch.h" +#ifdef XCSECURITY +#define _SECURITY_SERVER +#include +#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; iname) == 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; inum) + { + 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; itrustLevel == 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; itrustLevel == 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 +#endif + +#include +#include +#include +#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 + +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; inumInDashList; 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; inumDepths; 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 +#endif + +#include +#include +#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 +#endif + +#include "misc.h" +#include +#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 +#endif + +#include +#include "misc.h" +#define NEED_EVENTS +#include +#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 +#endif + +#include +#include +#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 +#endif + +#include +#include /* for unistd.h */ +#include +#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 +#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 +#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; iCreateScreenResources && + !(*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; idrawable.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; formatrgf = ~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 +#endif + +#include +#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 +#endif + +#include +#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 +#endif + +#include +#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 +#endif + +#include +#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 +#endif + +#include +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include "windowstr.h" +#include "propertyst.h" +#include "dixstruct.h" +#include "dispatch.h" +#include "swaprep.h" +#ifdef XCSECURITY +#define _SECURITY_SERVER +#include +#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 +#endif + +#include +#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 + +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>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 +#endif + +#include +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include "misc.h" +#include "dixstruct.h" +#include +#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 +#endif + +#include +#define NEED_EVENTS +#include +#include +#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 +#endif + +#include +#define NEED_EVENTS +#define NEED_REPLIES +#include +#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 +#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 +#endif +#ifdef XCSECURITY +#define _SECURITY_SERVER +#include +#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; idrawable.id); + miPrintRegion(&p1->clipList); + PrintChildren(p2, indent+4); + p1 = p1->nextSib; + } +} + +PrintWindowTree() +{ + int i; + WindowPtr pWin, p1; + + for (i=0; iclipList); + 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; jnumSaved; 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; jwidth + 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 +#endif + +#include "misc.h" +#include +#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 + +#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 + +#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 + +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#endif + +#include +#include +#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 +#endif + +#include "fb.h" + +#ifdef RENDER + +#include "picturestr.h" +#include "mipict.h" +#include "fbpict.h" +#include + +#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 (®ion, + 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 (®ion); + pbox = REGION_RECTS (®ion); + 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, ®ion); + + 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 +#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 + +#ifdef HAVE_DIX_CONFIG_H +#include +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#endif + +#include "fb.h" +#include +#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 +#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 +#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 +#endif + +#ifdef USE_MMX + +#if defined(__amd64__) || defined(__x86_64__) +#define USE_SSE +#endif + +#include +#include /* 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 +#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 +#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 +#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 +#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 (®ion, + pSrc, + pMask, + pDst, + xSrc, + ySrc, + xMask, + yMask, + xDst, + yDst, + width, + height)) + return; + + n = REGION_NUM_RECTS (®ion); + pbox = REGION_RECTS (®ion); + 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, ®ion); +} + +#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 +#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 +#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 +#else +#include +#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 +#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 +#endif + +#include +#include +#include "scrnintstr.h" +#include "colormapst.h" +#include "glyphstr.h" +#include "resource.h" +#include +#include "dixfontstr.h" +#include +#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, ®ion, &box, 1); \ + REGION_INTERSECT(pScreen,®ion,®ion,\ + (pGC)->pCompositeClip);\ + if (REGION_NOTEMPTY(pScreen,®ion)) { \ + xxScrPriv(pScreen);\ + PRINT_RECTS(pScrPriv->region);\ + REGION_UNION(pScreen,&pScrPriv->region,&pScrPriv->region,®ion);\ + PRINT_RECTS(pScrPriv->region);\ + REGION_UNINIT(pScreen,®ion);\ + }\ + }\ +} + +#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, ®ion, &box, 1); \ + PRINT_RECTS(pScrPriv->region);\ + REGION_UNION(pScreen,&pScrPriv->region,&pScrPriv->region,®ion);\ + PRINT_RECTS(pScrPriv->region);\ + REGION_UNINIT(pScreen,®ion);\ + }\ +} + +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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 +#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 + +LinkSourceFile(InfoPlist.strings.cpp,../English.lproj) + +INCLUDES = -I$(SERVERSRC)/include + +#if defined (XorgVersionString) +VERS = XorgVersionString +PRE = XORG_VERSION_SNAP +NAME = "X Version 11" +LINK = 'X.Org Foundation' +#elif defined XFree86VersionString +VERS = XFree86VersionString +PRE = XF86_VERSION_SNAP +NAME = "XFree86" +LINK = 'XFree86 Project, Inc.' +#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) $@ + +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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/Localizable.strings 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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/objects.nib 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 @@ + + + + +XDarwin Help + + +
+

XDarwin X Server for Mac OS X

+ X_VENDOR_NAME X_VERSION
+ Release Date: X_REL_DATE +
+

Inhoud

+
    +
  1. Belangrijke Informatie
  2. +
  3. Gebruik
  4. +
  5. Instellen van het Path
  6. +
  7. Voorkeursinstellingen
  8. +
  9. Licentie
  10. +
+
+

Belangrijke Informatie

+
+
+#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 XonX project pagina bij SourceForge. Kijk alvorens een bug te rapporteren in een pre-release eerst of een nieuwe versie beschikbaar is bij XonX 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 XonX project pagina bij SourceForge. +#endif +
+
+Deze software is beschikbaar gesteld onder de voorwaarden van de MIT X11 / X Consortium Licentie en is beschikbaar 'AS IS',zonder enige garantie. Lees s.v.p. de Licentie voor gebruik.
+ +

Gebruik

+

XDarwin is een open-source X server van het X Window Systeem. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin werkt op Mac OS X in schermvullende of rootless modus.

+

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

+

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.

+ +

Meerknopsmuis emulatie

+

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.

+ +

Instellen van het Path

+

Het path is de lijst van directories waarin gezocht wordt naar commando's. De X11 commando's staan in de directory /usr/X11R6/bin, 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ïnstalleerd.

+ +

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.

+ +

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 /usr/X11R6/man en de MANPATH environment variable bevat de lijst van directories waarin naar documentatie wordt gezocht.

+ +

Voorkeursinstellingen

+

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:

+ +

Algemeen

+
    +
  • Gebruik systeempiep voor X11: Als u dit inschakelt wordt het Mac OS X waarschuwingssignaal ook gebruikt door X11, anders gebruikt X11 een simpele pieptoon (dit is de standaardinstelling).
  • +
  • Wijzigen muis-versnelling door X11 mogelijk: 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.
  • +
  • Meerknopsmuis emulatie: Dit is hierboven beschreven bij Gebruik. 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.
  • +
+ +

Start

+
    +
  • Standaard modus: Hier kiest u de standaard scherm-modus: schermvullend of rootless (hierboven beschreven bij Gebruik). U kunt ook kiezen tijdens het starten van XDarwin, zie de optie hieronder.
  • +
  • Kies scherm-modus tijdens start: 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.
  • +
  • X11 scherm nummer: 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.
  • +
  • Xinerama multi-monitor ondersteuning mogelijk: XDarwin ondersteunt het gebruik van meerdere monitoren met Xinerama, waarbij elke monitor wordt gezien als deel van éé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.
  • +
  • Toetsenbordindeling-bestand: Een toetsenbordindeling-bestand wordt bij het starten geladen en omgezet naar een X11 toetsenbordindeling. Voor verschillende talen vindt u toetsenbordindelingen in de directory /System/Library/Keyboards.
  • +
  • Bij starten eerste X11 clients: Als XDarwin start, wordt xinit uitgevoerd om de X window manager en andere X clients te starten (zie "man xinit"). Voordat XDarwin xinit uitvoert voegt het de opgegeven directories toe aan het path. Standaard wordt alleen /usr/X11R6/bin 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.
  • +
+ +

Schermvullend

+
    +
  • Toetscombinatie knop: 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 één normale toets.
  • +
  • Klikken op icoon in Dock schakelt naar X11: 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.
  • +
  • Toon help bij schermvullend starten: Hiermee wordt een inleidend scherm getoond als XDarwin schermvullend start.
  • +
  • Kleurdiepte: 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.
  • +
+ +

Licentie

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

X Consortium License

+

Copyright (C) 1996 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.

+

X Window System is a trademark of X Consortium, Inc.

+ + + 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 + +INCLUDES = -I$(SERVERSRC)/include + +#if defined (XorgVersionString) +VERS = XorgVersionString +PRE = XORG_VERSION_SNAP +NAME = "X Version 11" +LINK = 'X.Org Foundation' +#elif defined XFree86VersionString +VERS = XFree86VersionString +PRE = XF86_VERSION_SNAP +NAME = "XFree86" +LINK = 'XFree86 Project, Inc.' +#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) $@ + +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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib 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 @@ + + + + +XDarwin Help + + +
+

XDarwin X Server for Mac OS X

+ X_VENDOR_NAME X_VERSION
+ Release Date: X_REL_DATE +
+

Contents

+
    +
  1. Important Notice
  2. +
  3. Usage
  4. +
  5. Setting Your Path
  6. +
  7. User Preferences
  8. +
  9. License
  10. +
+
+

Important Notice

+
+
+#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 XonX project page at SourceForge. Before reporting bugs in pre-release versions, please check the latest version from XonX 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 XonX project page at SourceForge. +#endif +
+
+This software is distributed under the terms of the MIT X11 / X Consortium License and is provided AS IS, with no warranty. Please read the License before using.
+ +

Usage

+

XDarwin is a freely redistributable open-source X server for the X Window System. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin runs on Mac OS X in full screen or rootless modes.

+

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

+

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.

+

Multi-Button Mouse Emulation

+

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.

+ +

Setting Your Path

+

Your path is the list of directories to be searched for executable commands. The X11 commands are located in /usr/X11R6/bin, 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.

+

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.

+

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 /usr/X11R6/man and the MANPATH environment variable contains the list of directories to search.

+ +

User Preferences

+

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:

+

General

+
    +
  • Use System beep for X11: When enabled the standard Mac OS X alert sound is used as the X11 bell. When disabled (default) a simple tone is used.
  • +
  • Allow X11 to change mouse acceleration: 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.
  • +
  • Multi-Button Mouse Emulation: This is described above under Usage. 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.
  • +
+

Start Up

+
    +
  • Default Mode: If the user does not indicate whether to run in full screen or rootless mode, the mode specified here will be used.
  • +
  • Show mode pick panel on startup: 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.
  • +
  • X11 Display number: 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.
  • +
  • Allow Xinerama multiple monitor support: 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.
  • +
  • Keymapping File: 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 /System/Library/Keyboards.
  • +
  • Starting First X11 Clients: When XDarwin is started from the Finder, it will run xinit to launch the X window manager and other X clients. (See "man xinit" for more information.) Before XDarwin runs xinit it will add the specified directories to the user's path. By default only /usr/X11R6/bin 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.
  • +
+

Full Screen

+
    +
  • Key combination button: 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.
  • +
  • Click on icon in Dock switches to X11: 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.
  • +
  • Show help on startup: This will show an introductory splash screen when XDarwin is started in full screen mode.
  • +
  • Color bit depth: 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.
  • +
+ +

License

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

X Consortium License

+

Copyright (C) 1996 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.

+

X Window System is a trademark of X Consortium, Inc.

+ + 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 + +LinkSourceFile(InfoPlist.strings.cpp,../English.lproj) + +INCLUDES = -I$(SERVERSRC)/include + +#if defined (XorgVersionString) +VERS = XorgVersionString +PRE = XORG_VERSION_SNAP +NAME = "X Version 11" +LINK = 'X.Org Foundation' +#elif defined XFree86VersionString +VERS = XFree86VersionString +PRE = XF86_VERSION_SNAP +NAME = "XFree86" +LINK = 'XFree86 Project, Inc.' +#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) $@ + +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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/Localizable.strings 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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/French.lproj/MainMenu.nib/objects.nib 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 @@ + + + + +XDarwin Help + + +
+

XDarwin X Server pour Mac OS X

+ X_VENDOR_NAME X_VERSION
+ Date : X_REL_DATE +
+

Sommaire

+
    +
  1. Avertissement
  2. +
  3. Utilisation
  4. +
  5. Chemins d'accès
  6. +
  7. Préférences
  8. +
  9. Licence
  10. +
+
+

Avertissement

+
+
+#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 +page du projet XonX chez SourceForge. Veuillez prendre connaissance de la dernière version sur XonX 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 page du projet XonX chez SourceForge. +#endif +
+
+Ce logiciel est distribué sous la +Licence du Consortium X/X11 du MIT et est fourni TEL QUEL, sans garanties. Veuillez prendre connaissance de la Licence avant toute utilisation.
+ +

Utilisation

+

XDarwin est une X server libre et distribuable sans contrainte du X Window System. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin fonctionne sous Mac OS X en mode « rootless » ou plein écran.

+

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)

+

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.

+

Émulation de souris à plusieurs boutons

+

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

Réglage du chemin d'accès

+

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 /usr/X11R6/bin, 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.

+

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.

+

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 /usr/X11R6/man et la variable d'environnement MANPATH contient la liste des répertoires dans lesquels chercher.

+ + +

Préférences

+

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 :

+

Général

+
    +
  • Utiliser le bip d'alerte Système dans X11 : 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é.
  • +
  • Autoriser X11 à changer la vitesse de la souris : 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.
  • +
  • Émulation de souris à plusieurs boutons : Ceci est décrit ci-dessus à la rubrique Usage. 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.
  • +
+

Démarrage

+
    +
  • Mode par défaut : Le mode spécifié à cet endroit sera utilisé si l'utilisateur ne l'indique pas au démarrage.
  • +
  • Choix du mode d'affichage au démarrage 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é.
  • +
  • Numéro d'affichage (Display) 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.
  • +
  • Autoriser la prise en charge Xinerama de plusieurs moniteurs : 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é.
  • +
  • Fichier clavier : 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 /System/Library/Keyboards.
  • +
  • Démarrage des premiers clients X11 : Lorsque XDarwin est démarré à partir du Finder, il lance xinit qui lance à son tour le gestionnaire X window ainsi que d'autres clients X. (Voir "man xinit" pour plus d'informations.) Avant de lancer xinit, XDarwin ajoute les répertoires ainsi spécifiés au chemin d'accès de l'utilisateur. Par défaut, seul /usr/X11R6/bin est ajouté. Il est possible d'ajouter d'autres répertoires en les séparants à l'aide de deux points (:). 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é.
  • +
+

Plein écran

+
    +
  • Combinaison de touches : 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.
  • +
  • Basculer dans X11 en cliquant sur l'icône du Dock : 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.
  • +
  • Afficher l'aide du mode plein écran au démarrage : Permet l'affichage d'une fenêtre d'introduction lorsque XDarwin est démarré en mode plein écran.
  • +
  • Profondeur de couleur : 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).
  • +
+ +

Licence

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

X Consortium License

+

Copyright (C) 1996 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.

+

X Window System is a trademark of X Consortium, Inc.

+ + + 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 + +LinkSourceFile(InfoPlist.strings.cpp,../English.lproj) + +INCLUDES = -I$(SERVERSRC)/include + +#if defined (XorgVersionString) +VERS = XorgVersionString +PRE = XORG_VERSION_SNAP +NAME = "X Version 11" +LINK = 'X.Org Foundation' +#elif defined XFree86VersionString +VERS = XFree86VersionString +PRE = XF86_VERSION_SNAP +NAME = "XFree86" +LINK = 'XFree86 Project, Inc.' +#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) $@ + +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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/Localizable.strings 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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/German.lproj/MainMenu.nib/objects.nib 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 @@ + + + + +XDarwin Help + + +
+

XDarwin X Server for Mac OS X

+ X_VENDOR_NAME X_VERSION
+ Release Date: X_REL_DATE +
+

Contents

+
    +
  1. Important Notice
  2. +
  3. Usage
  4. +
  5. Setting Your Path
  6. +
  7. User Preferences
  8. +
  9. License
  10. +
+
+

Important Notice

+
+
+#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 XonX project page at SourceForge. Before reporting bugs in pre-release versions, please check the latest version from XonX 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 XonX project page at SourceForge. +#endif +
+
+This software is distributed under the terms of the MIT X11 / X Consortium License and is provided AS IS, with no warranty. Please read the License before using.
+ +

Usage

+

XDarwin is a freely redistributable open-source X server for the X Window System. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin runs on Mac OS X in full screen or rootless modes.

+

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

+

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.

+

Multi-Button Mouse Emulation

+

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.

+ +

Setting Your Path

+

Your path is the list of directories to be searched for executable commands. The X11 commands are located in /usr/X11R6/bin, 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.

+

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.

+

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 /usr/X11R6/man and the MANPATH environment variable contains the list of directories to search.

+ +

User Preferences

+

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:

+

General

+
    +
  • Use System beep for X11: When enabled the standard Mac OS X alert sound is used as the X11 bell. When disabled (default) a simple tone is used.
  • +
  • Allow X11 to change mouse acceleration: 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.
  • +
  • Multi-Button Mouse Emulation: This is described above under Usage. 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.
  • +
+

Start Up

+
    +
  • Default Mode: If the user does not indicate whether to run in full screen or rootless mode, the mode specified here will be used.
  • +
  • Show mode pick panel on startup: 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.
  • +
  • X11 Display number: 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.
  • +
  • Allow Xinerama multiple monitor support: 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.
  • +
  • Keymapping File: 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 /System/Library/Keyboards.
  • +
  • Starting First X11 Clients: When XDarwin is started from the Finder, it will run xinit to launch the X window manager and other X clients. (See "man xinit" for more information.) Before XDarwin runs xinit it will add the specified directories to the user's path. By default only /usr/X11R6/bin 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.
  • +
+

Full Screen

+
    +
  • Key combination button: 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.
  • +
  • Click on icon in Dock switches to X11: 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.
  • +
  • Show help on startup: This will show an introductory splash screen when XDarwin is started in full screen mode.
  • +
  • Color bit depth: 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.
  • +
+ +

License

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

X Consortium License

+

Copyright (C) 1996 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.

+

X Window System is a trademark of X Consortium, Inc.

+ + 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 +#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 + +LinkSourceFile(InfoPlist.strings.cpp,../English.lproj) + +INCLUDES = -I$(SERVERSRC)/include + +#if defined (XorgVersionString) +VERS = XorgVersionString +PRE = XORG_VERSION_SNAP +NAME = "X Version 11" +LINK = 'X.Org Foundation' +#elif defined XFree86VersionString +VERS = XFree86VersionString +PRE = XF86_VERSION_SNAP +NAME = "XFree86" +LINK = 'XFree86 Project, Inc.' +#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) $@ + +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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/Localizable.strings 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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/objects.nib 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 @@ + + + + + + +XDarwin Help + +
+

XDarwin X Server for Mac OS X

+ X_VENDOR_NAME X_VERSION
+ Release Date: X_REL_DATE +
+

Ìܼ¡

+
    +
  1. Ãí°Õ»ö¹à
  2. +
  3. »ÈÍÑË¡
  4. +
  5. ¥Ñ¥¹¤ÎÀßÄê
  6. +
  7. ´Ä¶­ÀßÄê
  8. +
  9. ¥é¥¤¥»¥ó¥¹
  10. +
+
+

Ãí°Õ»ö¹à

+
+
+#if X_PRE_RELEASE +¤³¤ì¤Ï¡¤XDarwin ¤Î¥×¥ì¥ê¥ê¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¤Ç¤¢¤ê¡¤¤¤¤«¤Ê¤ë¾ì¹ç¤Ë¤ª¤¤¤Æ¤â¥µ¥Ý¡¼¥È¤µ¤ì¤Þ¤»¤ó¡£ +¥Ð¥°¤ÎÊó¹ð¤ä¥Ñ¥Ã¥Á¤¬ SourceForge ¤Î XonX ¥×¥í¥¸¥§¥¯¥È¥Ú¡¼¥¸¤ËÄó½Ð¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ +¥×¥ì¥ê¥ê¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¤Î¥Ð¥°¤òÊó¹ð¤¹¤ëÁ°¤Ë¡¤XonX ¥×¥í¥¸¥§¥¯¥È¥Ú¡¼¥¸¤Þ¤¿¤Ï X_VENDOR_LINK¤ÇºÇ¿·ÈǤΥÁ¥§¥Ã¥¯¤ò¤·¤Æ²¼¤µ¤¤¡£ +#else +¤â¤·¡¤¥µ¡¼¥Ð¡¼¤¬ 6 -12 ¥ö·î°Ê¾åÁ°¤Î¤â¤Î¤«¡¤¤Þ¤¿¤Ï¤¢¤Ê¤¿¤Î¥Ï¡¼¥É¥¦¥§¥¢¤¬¾åµ­¤ÎÆüÉÕ¤è¤ê¤â¿·¤·¤¤¤â¤Î¤Ê¤é¤Ð¡¤ÌäÂê¤òÊó¹ð¤¹¤ëÁ°¤Ë¤è¤ê¿·¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤òõ¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£ +¥Ð¥°¤ÎÊó¹ð¤ä¥Ñ¥Ã¥Á¤¬ SourceForge ¤Î XonX ¥×¥í¥¸¥§¥¯¥È¥Ú¡¼¥¸¤ËÄó½Ð¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£ +#endif +
+
+ËÜ¥½¥Õ¥È¥¦¥§¥¢¤Ï¡¤MIT X11/X Consortium License ¤Î¾ò·ï¤Ë´ð¤Å¤­¡¤ÌµÊݾڤǡ¤¡Ö¤½¤Î¤Þ¤Þ¡×¤Î·Á¤Ç¶¡µë¤µ¤ì¤Þ¤¹¡£ +¤´»ÈÍѤˤʤëÁ°¤Ë¡¤¥é¥¤¥»¥ó¥¹¾ò·ï¤ò¤ªÆÉ¤ß²¼¤µ¤¤¡£ +
+ +

»ÈÍÑË¡

+

XDarwin ¤Ï¡¤ºÆÇÛÉÛ²Äǽ¤Ê¥ª¡¼¥×¥ó¥½¡¼¥¹¤Î X Window System ¤Î¤¿¤á¤Î X ¥µ¡¼¥Ð¡¼¤Î¼ÂÁõ¤Ç¤¹¡£¤³¤Î¥Ð¡¼¥¸¥ç¥ó¤Î XDarwin ¤Ï X_VENDOR_LINK ¤Ë¤è¤Ã¤ÆºîÀ®¤µ¤ì¤Þ¤·¤¿¡£XDarwin ¤Ï¡¤Mac OS X ¾å¤Ç¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Þ¤¿¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Çưºî¤·¤Þ¤¹¡£

+ +

¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Ç¤Ï¡¤X Window System ¤¬¥¢¥¯¥Æ¥£¥Ö¤Ê»þ¡¤¤½¤ì¤ÏÁ´²èÌ̤òÀêÍ­¤·¤Þ¤¹¡£ +¤¢¤Ê¤¿¤Ï¡¤Command-Option-A ¥­¡¼¤ò²¡¤¹¤³¤È¤Ë¤è¤Ã¤Æ Mac OS X ¥Ç¥¹¥¯¥È¥Ã¥×¤ØÀÚ¤êÂØ¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤³¤Î¥­¡¼¤ÎÁȤ߹ç¤ï¤»¤Ï¡¤´Ä¶­ÀßÄê¤ÇÊѹ¹²Äǽ¤Ç¤¹¡£ +Mac OS X ¥Ç¥¹¥¯¥È¥Ã¥×¤«¤é X Window System ¤ØÀÚ¤êÂØ¤¨¤ë¾ì¹ç¤Ï¡¤¥É¥Ã¥¯¤Ëɽ¼¨¤µ¤ì¤¿ XDarwin ¥¢¥¤¥³¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ²¼¤µ¤¤¡£ +¡Ê´Ä¶­ÀßÄê¤Ç¡¤¥Õ¥í¡¼¥Æ¥£¥ó¥°¡¦¥¦¥£¥ó¥É¥¦¤Ëɽ¼¨¤µ¤ì¤¿ XDarwin ¥¢¥¤¥³¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤è¤¦¤ËÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¡Ë

+ +

¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Ç¤Ï¡¤X Window System ¤È Aqua ¤Ï²èÌ̤ò¶¦Í­¤·¤Þ¤¹¡£ +X11 ¤¬É½¼¨¤¹¤ë¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤Ï²èÌ̤Υµ¥¤¥º¤Ç¤¢¤ê¡¤Â¾¤ÎÁ´¤Æ¤Î¥¦¥£¥ó¥É¥¦¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£ +Aqua ¤¬¥Ç¥¹¥¯¥È¥Ã¥×¤ÎÇØ·Ê¤òÀ©¸æ¤¹¤ë¤Î¤Ç¡¤X11 ¤Î¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Ç¤Ïɽ¼¨¤µ¤ì¤Þ¤»¤ó¡£

+ +

Ê£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó

+

¿¤¯¤Î X11 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¤3 ¥Ü¥¿¥ó¥Þ¥¦¥¹¤òɬÍפȤ·¤Þ¤¹¡£ +¤¢¤Ê¤¿¤Ï¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ÈƱ»þ¤Ë¤¤¤¯¤Ä¤«¤Î½¤¾þ¥­¡¼¤ò²¡¤¹¤³¤È¤Ë¤è¤Ã¤Æ¡¤°ì¤Ä¤Î¥Ü¥¿¥ó¤Ç 3 ¥Ü¥¿¥ó¥Þ¥¦¥¹¤ò¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ +¤³¤ì¤Ï¡¤´Ä¶­ÀßÄê¤Î¡Ö°ìÈÌÀßÄê¡×¤Î¡ÖÊ£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¡×¥»¥¯¥·¥ç¥ó¤ÇÀßÄꤷ¤Þ¤¹¡£ +¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¤¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤ÏÍ­¸ú¤Ç¡¤¥³¥Þ¥ó¥É¥­¡¼¤ò²¡¤·¤Ê¤¬¤é¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤³¤È¤ÏÂè 2 ¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ËÁêÅö¤·¤Þ¤¹¡£ +¥ª¥×¥·¥ç¥ó¥­¡¼¤ò²¡¤·¤Ê¤¬¤é¥¯¥ê¥Ã¥¯¤¹¤ë¤³¤È¤ÏÂè 3 ¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ËÁêÅö¤·¤Þ¤¹¡£ +¤¢¤Ê¤¿¤Ï¡¤´Ä¶­ÀßÄê¤Ç¥Ü¥¿¥ó 2 ¤È 3 ¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë½¤¾þ¥­¡¼¤ÎÁȹ礻¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ +Ãí¡§½¤¾þ¥­¡¼¤ò xmodmap ¤Ç¾¤Î¥­¡¼¤Ë³ä¤êÅö¤Æ¤Æ¤¤¤ë¾ì¹ç¤Ç¤â¡¤Ê£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤Ç¤ÏËÜÍè¤Î¥³¥Þ¥ó¥É¥­¡¼¤ä¥ª¥×¥·¥ç¥ó¥­¡¼¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£

+ +

¥Ñ¥¹¤ÎÀßÄê

+

¥Ñ¥¹¤Ï¡¤ ¼Â¹Ô²Äǽ¤Ê¥³¥Þ¥ó¥É¤ò¸¡º÷¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤Î¥ê¥¹¥È¤Ç¤¹¡£ +X11 ¥Ð¥¤¥Ê¥ê¤Ï¡¤/usr/X11R6/bin ¤ËÃÖ¤«¤ì¤Þ¤¹¡£¤¢¤Ê¤¿¤Ï¤½¤ì¤ò¥Ñ¥¹¤Ë²Ã¤¨¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ +XDarwin ¤Ï¡¤¤³¤ì¤ò¥Ç¥Õ¥©¥ë¥È¤Ç¹Ô¤¤¤Þ¤¹¡£¤Þ¤¿¡¤¤¢¤Ê¤¿¤¬¥³¥Þ¥ó¥É¥é¥¤¥ó¡¦¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤¿ÄɲäΥǥ£¥ì¥¯¥È¥ê¤ò²Ã¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

+ +

·Ð¸³Ë­¤«¤Ê¥æ¡¼¥¶¡¼¤Ï¡¤¤¹¤Ç¤Ë¼«¤é¤Î¥·¥§¥ë¤Î¤¿¤á¤Ë½é´ü²½¥Õ¥¡¥¤¥ë¤ò»ÈÍѤ·¤Æ¥Ñ¥¹¤òÀßÄꤷ¤Æ¤¤¤ë¤Ç¤·¤ç¤¦¡£ +¤³¤Î¾ì¹ç¡¤¤¢¤Ê¤¿¤Ï´Ä¶­ÀßÄê¤Ç XDarwin ¤¬¤¢¤Ê¤¿¤Î¥Ñ¥¹¤òÊѹ¹¤·¤Ê¤¤¤è¤¦¤ËÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ +XDarwin ¤Ï¡¤¥æ¡¼¥¶¡¼¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥í¥°¥¤¥ó¥·¥§¥ë¤ÇºÇ½é¤Î X11 ¥¯¥é¥¤¥¢¥ó¥È¤ò³«»Ï¤·¤Þ¤¹¡£ +¡Ê´Ä¶­ÀßÄê¤ÇÂå¤ï¤ê¤Î¥·¥§¥ë¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¡Ë +¥Ñ¥¹¤òÀßÄꤹ¤ëÊýË¡¤Ï¡¤¤¢¤Ê¤¿¤¬»ÈÍѤ·¤Æ¤¤¤ë¥·¥§¥ë¤Ë°Í¸¤·¤Þ¤¹¡£ +¤³¤ì¤Ï¡¤¥·¥§¥ë¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¥É¥­¥å¥á¥ó¥È¤Ëµ­ºÜ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£ + +

¤Þ¤¿¡¤¤¢¤Ê¤¿¤Ï¥É¥­¥å¥á¥ó¥È¤òõ¤·¤Æ¤¤¤ë»þ¡¤X11 ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ò¸¡º÷¤µ¤ì¤ë¥Ú¡¼¥¸¤Î¥ê¥¹¥È¤ËÄɲä·¤¿¤¤¤È»×¤¦¤«¤â¤·¤ì¤Þ¤»¤ó¡£ +X11 ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ï /usr/X11R6/man ¤ËÃÖ¤«¤ì¤Þ¤¹¡£¤½¤·¤Æ MANPATH ´Ä¶­ÊÑ¿ô¤Ï¸¡º÷¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤Î¥ê¥¹¥È¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£

+ +

´Ä¶­ÀßÄê

+

¡ÖXDarwin¡×¥á¥Ë¥å¡¼¤Î¡Ö´Ä¶­ÀßÄê...¡×¥á¥Ë¥å¡¼¹àÌܤ«¤é¥¢¥¯¥»¥¹¤Ç¤­¤ë´Ä¶­ÀßÄê¥Ñ¥Í¥ë¤Ç¡¤¤¤¤¯¤Ä¤«¤Î¥ª¥×¥·¥ç¥ó¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ +¡Öµ¯Æ°¥ª¥×¥·¥ç¥ó¡×¤ÎÆâÍÆ¤Ï¡¤XDarwin ¤òºÆµ¯Æ°¤¹¤ë¤Þ¤ÇÍ­¸ú¤È¤Ê¤ê¤Þ¤»¤ó¡£ +¾¤ÎÁ´¤Æ¤Î¥ª¥×¥·¥ç¥ó¤ÎÆâÍÆ¤Ï¡¤Ä¾¤Á¤ËÍ­¸ú¤È¤Ê¤ê¤Þ¤¹¡£ +°Ê²¼¡¤¤½¤ì¤¾¤ì¤Î¥ª¥×¥·¥ç¥ó¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹:

+ +

°ìÈÌÀßÄê

+
    +
  • X11 ¤Ç¥·¥¹¥Æ¥à¤Î¥Ó¡¼¥×²»¤ò»ÈÍѤ¹¤ë: ¥ª¥ó¤Î¾ì¹ç¡¤Mac OS X ¤Î¥Ó¡¼¥×²»¤¬ X11 ¤Î¥Ù¥ë¤È¤·¤Æ»ÈÍѤµ¤ì¤Þ¤¹¡£¥ª¥Õ¤Î¾ì¹ç¡Ê¥Ç¥Õ¥©¥ë¥È¡Ë¡¤¥·¥ó¥×¥ë ¥È¡¼¥ó¤¬»È¤ï¤ì¤Þ¤¹¡£
  • +
  • X11 ¤Î¥Þ¥¦¥¹¥¢¥¯¥»¥é¥ì¡¼¥·¥ç¥ó¤òÍ­¸ú¤Ë¤¹¤ë: ɸ½àŪ¤Ê X Window System ¤Î¼ÂÁõ¤Ç¤Ï¡¤¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¡¼¤Ï¥Þ¥¦¥¹¤Î²Ã®ÅÙ¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£ + ¥Þ¥¦¥¹¤Î²Ã®ÅÙ¤Ë Mac OS X ¤Î¥·¥¹¥Æ¥à´Ä¶­ÀßÄê¤È X ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¡¼¤¬°Û¤Ê¤ëÃͤòÀßÄꤷ¤¿¾ì¹ç¡¤¤³¤ì¤Ïº®Íð¤ò¾·¤­¤Þ¤¹¡£ + ¤³¤ÎÌäÂê¤òÈò¤±¤ë¤¿¤á¡¤¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï X11 ¤Î¥Þ¥¦¥¹¥¢¥¯¥»¥é¥ì¡¼¥·¥ç¥ó¤òÍ­¸ú¤È¤·¤Þ¤»¤ó¡£
  • +
  • Ê£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó: »ÈÍÑË¡¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£¥ª¥ó¤Î¾ì¹ç¡¤¥Þ¥¦¥¹¥Ü¥¿¥ó¤¬Âè 2 ¤Þ¤¿¤ÏÂè 3 ¤Î¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë»þ¤Ë¡¤ÁªÂò¤·¤¿½¤¾þ¥­¡¼¤òƱ»þ¤Ë²¡¤·¤Þ¤¹¡£
  • +
+ +

µ¯Æ°¥ª¥×¥·¥ç¥ó

+
    +
  • ²èÌ̥⡼¥É: ¥æ¡¼¥¶¡¼¤¬¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Þ¤¿¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Î¤É¤Á¤é¤ò»ÈÍѤ¹¤ë¤«¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¡¤¤³¤³¤Ç»ØÄꤵ¤ì¤¿¥â¡¼¥É¤¬»È¤ï¤ì¤Þ¤¹¡£
  • +
  • µ¯Æ°»þ¤Ë¥â¡¼¥ÉÁªÂò¥Ñ¥Í¥ë¤òɽ¼¨¤¹¤ë: ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¤XDarwin ¤Îµ¯Æ°»þ¤Ë¥æ¡¼¥¶¡¼¤¬¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Þ¤¿¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Î¤É¤Á¤é¤ò»ÈÍѤ¹¤ë¤«¤òÁªÂò¤¹¤ë¥Ñ¥Í¥ë¤òɽ¼¨¤·¤Þ¤¹¡£¤³¤Î¥ª¥×¥·¥ç¥ó¤¬¥ª¥Õ¤Î¾ì¹ç¡¤²èÌ̥⡼¥É¤Ç»ØÄꤷ¤¿¥â¡¼¥É¤Çµ¯Æ°¤·¤Þ¤¹¡£
  • +
  • X11 ¥Ç¥£¥¹¥×¥ì¥¤ÈÖ¹æ: X11¤Ï¡¤°ì¤Ä¤Î¥³¥ó¥Ô¥å¡¼¥¿¾å¤ÇÊÌ¡¹¤Î X ¥µ¡¼¥Ð¡¼¤¬´ÉÍý¤¹¤ëÊ£¿ô¤Î¥Ç¥£¥¹¥×¥ì¥¤¤¬Â¸ºß¤¹¤ë¤³¤È¤òµö¤·¤Þ¤¹¡£Ê£¿ô¤Î X ¥µ¡¼¥Ð¡¼¤¬Æ±»þ¤Ë¼Â¹Ô¤·¤Æ¤¤¤ë»þ¡¤XDarwin ¤¬»ÈÍѤ¹¤ë¥Ç¥£¥¹¥×¥ì¥¤¤ÎÈÖ¹æ¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
  • +
  • Xinerama ¥Þ¥ë¥Á¥â¥Ë¥¿¥µ¥Ý¡¼¥È¤òÍ­¸ú¤Ë¤¹¤ë: XDarwin ¤Ï¡¤Xinerama ¥Þ¥ë¥Á¥â¥Ë¥¿¤ò¥µ¥Ý¡¼¥È¤·¤Þ¤¹¡£¤½¤ì¤ÏÁ´¤Æ¤Î¥â¥Ë¥¿¤ò°ì¤Ä¤ÎÂ礭¤Ê²èÌ̤ΰìÉô¤È¤ß¤Ê¤·¤Þ¤¹¡£¤¢¤Ê¤¿¤Ï¤³¤Î¥ª¥×¥·¥ç¥ó¤Ç Xinerama ¤ò̵¸ú¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤¿¤À¤·¡¤¸½ºß XDarwin ¤Ï¤½¤ì̵¤·¤ÇÀµ¤·¤¯Ê£¿ô¤Î¥â¥Ë¥¿¤ò°·¤¦¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡£¤â¤·¡¤¤¢¤Ê¤¿¤¬°ì¤Ä¤Î¥â¥Ë¥¿¤ò»È¤¦¤À¤±¤Ê¤é¤Ð¡¤Xinerama ¤Ï¼«Æ°Åª¤Ë̵¸ú¤È¤Ê¤ê¤Þ¤¹¡£
  • +
  • ¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¥Õ¥¡¥¤¥ë: ¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¥Õ¥¡¥¤¥ë¤Ïµ¯Æ°»þ¤ËÆÉ¤ß¹þ¤Þ¤ì¡¤X11 ¥­¡¼¥Þ¥Ã¥×¤ËÊÑ´¹¤µ¤ì¤Þ¤¹¡£Â¾¸À¸ì¤ËÂбþ¤·¤¿¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¥Õ¥¡¥¤¥ë¤Ï /System/Library/Keyboards ¤Ë¤¢¤ê¤Þ¤¹¡£¡ÊÌõÃí¡§¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¤Ç Japanese ¤òÁªÂò¤¹¤ë¤È¡¤°ìÉô¤Î¥­¡¼¤¬¸ú¤«¤Ê¤¤Åù¤ÎÉÔ¶ñ¹ç¤¬È¯À¸¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£¤³¤Î¾ì¹ç¤Ï USA ¤òÁªÂò¤·¤¿¾å¤Ç ~/.Xmodmap ¤òŬÍѤ·¤Æ²¼¤µ¤¤¡£¡Ë
  • +
  • ºÇ½é¤Î X11 ¥¯¥é¥¤¥¢¥ó¥È¤Îµ¯Æ°: XDarwin ¤¬ Finder¤«¤éµ¯Æ°¤¹¤ë»þ¡¤X ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¡¼¤È X ¥¯¥é¥¤¥¢¥ó¥È¤Îµ¯Æ°¤Ï xinit ¤ò¼Â¹Ô¤·¤Þ¤¹¡£¡Ê¾ÜºÙ¤Ï "man xinit" ¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£¡ËXDarwin ¤Ï xinit ¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë¡¤»ØÄꤵ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ò¥æ¡¼¥¶¡¼¤Î¥Ñ¥¹¤ËÄɲä·¤Þ¤¹¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï /usr/X11R6/bin ¤À¤±¤òÄɲä·¤Þ¤¹¡£Â¾¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÄɲä·¤¿¤¤¾ì¹ç¤Ï¡¤¥³¥í¥ó¤Ç¶èÀڤäƻØÄꤷ¤Þ¤¹¡£¥æ¡¼¥¶¡¼¤Î¥·¥§¥ë½é´ü²½¥Õ¥¡¥¤¥ë¤òÆÉ¤ß¹þ¤à¤¿¤á¤Ë¡¤X ¥¯¥é¥¤¥¢¥ó¥È¤Ï¥æ¡¼¥¶¡¼¤Î¥Ç¥Õ¥©¥ë¥È¥í¥°¥¤¥ó¥·¥§¥ë¤Çµ¯Æ°¤µ¤ì¤Þ¤¹¡£É¬ÍפǤ¢¤ì¤Ð¡¤Âå¤ï¤ê¤Î¥·¥§¥ë¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
  • +
+ +

¥Õ¥ë¥¹¥¯¥ê¡¼¥ó

+
    +
  • ¥­¡¼ÀßÄê¥Ü¥¿¥ó: X11 ¤È Aqua ¤òÀÚ¤êÂØ¤¨¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¥Ü¥¿¥ó¤ÎÁȤ߹ç¤ï¤»¤ò»ØÄꤷ¤Þ¤¹¡£ + ¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¡¤Ç¤°Õ¤Î¿ô¤Î½¤¾þ¥­¡¼¤Ë³¤¤¤ÆÄ̾ï¤Î¥­¡¼¤ò²¡¤·¤Þ¤¹¡£
  • +
  • ¥É¥Ã¥¯¤Î¥¢¥¤¥³¥ó¤Î¥¯¥ê¥Ã¥¯¤Ç X11 ¤ËÌá¤ë: ¥ª¥ó¤Î¾ì¹ç¡¤¥É¥Ã¥¯¤Ëɽ¼¨¤µ¤ì¤¿ XDarwin ¥¢¥¤¥³¥ó¤Î¥¯¥ê¥Ã¥¯¤Ç X11 ¤Ø¤ÎÀڤ괹¤¨¤¬²Äǽ¤È¤Ê¤ê¤Þ¤¹¡£Mac OS X ¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¡¤¥É¥Ã¥¯¤Î¥¢¥¤¥³¥ó¤Î¥¯¥ê¥Ã¥¯¤Ç Aqua ¤ËÌá¤Ã¤¿»þ¡¤¥«¡¼¥½¥ë¤¬¾Ã¼º¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£
  • +
  • µ¯Æ°»þ¤Ë¥Ø¥ë¥×¤òɽ¼¨¤¹¤ë: XDarwin ¤¬¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Çµ¯Æ°¤¹¤ë»þ¡¤¥¹¥×¥é¥Ã¥·¥å¥¹¥¯¥ê¡¼¥ó¤òɽ¼¨¤·¤Þ¤¹¡£
  • +
  • ¿§¿¼ÅÙ: ¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Ç¤Ï¡¤X11 ¥Ç¥£¥¹¥×¥ì¥¤¤¬ Aqua ¤È°Û¤Ê¤ë¿§¿¼ÅÙ¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¡ÖÊѹ¹¤Ê¤·¡×¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¤XDarwin ¤Ï Aqua ¤Ë¤è¤Ã¤Æ»ÈÍѤµ¤ì¤ë¿§¿¼ÅÙ¤ò»È¤¤¤Þ¤¹¡£¤³¤ì°Ê³°¤Ë 8¡¤15 ¤Þ¤¿¤Ï24 ¥Ó¥Ã¥È¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
  • +
+ +

+¥é¥¤¥»¥ó¥¹ +

+XDarwin ¤Î¼çÍפʥ饤¥»¥ó¥¹¤ÏÅÁÅýŪ¤Ê MIT X11/X Consortium License ¤Ë´ð¤Å¤­¤Þ¤¹¡£ +¤½¤ì¤Ï½¤Àµ¤Þ¤¿¤ÏºÆÇÛÉÛ¤µ¤ì¤ë¥½¡¼¥¹¥³¡¼¥É¤Þ¤¿¤Ï¥Ð¥¤¥Ê¥ê¤Ë¡¤¤½¤ÎÃøºî¸¢/¥é¥¤¥»¥ó¥¹É½¼¨¤¬¤½¤Î¤Þ¤Þ»Ä¤µ¤ì¤ë¤³¤È¤òÍ׵᤹¤ë°Ê³°¤Î¾ò·ï¤ò¶¯À©¤·¤Þ¤»¤ó¡£ +¤è¤ê¿¤¯¤Î¾ðÊó¤È¡¤¥³¡¼¥É¤Î°ìÉô¤ò¥«¥Ð¡¼¤¹¤ëÄɲäÎÃøºî¸¢/¥é¥¤¥»¥ó¥¹É½¼¨¤Î¤¿¤á¤Ë¡¤¥½¡¼¥¹¥³¡¼¥É¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£ +

+ +X Consortium License

+

Copyright (C) 1996 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.

+

X Window System is a trademark of X Consortium, Inc.

+ + 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 + +LinkSourceFile(InfoPlist.strings.cpp,../English.lproj) + +INCLUDES = -I$(SERVERSRC)/include + +#if defined (XorgVersionString) +VERS = XorgVersionString +PRE = XORG_VERSION_SNAP +NAME = "X Version 11" +LINK = 'X.Org Foundation' +#elif defined XFree86VersionString +VERS = XFree86VersionString +PRE = XF86_VERSION_SNAP +NAME = "XFree86" +LINK = 'XFree86 Project, Inc.' +#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) $@ + +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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/Localizable.strings 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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/objects.nib 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 @@ + + + +XDarwin Help + + +
+ +

XDarwin X Server para Mac OS X

+ X_VENDOR_NAME X_VERSION
+ Release Date: X_REL_DATE +
+

Índice

+
    +
  1. Notas importantes
  2. +
  3. Uso
  4. +
  5. Ajustando seu Path
  6. + +
  7. Preferências do usuário
  8. +
  9. Licença
  10. +
+
+

Notas importantes

+
+
+#if PRE_RELEASE + Essa é uma versão pré-lancamento + do XDarwin, e ela não é suportada de nenhuma forma. Bugs podem + ser reportados e correções podem ser enviadas para Página + do projeto XonX no SourceForge. Antes de informar bugs em versões + pré-lancamento, por favor verifique a þltima versão em XonX + or X_VENDOR_LINK. +#else +Se o servidor é mais velho que 6-12 semanas, ou seu hardware é + mais novo que a data acima, procure por uma nova versão antes de informar + problemas. Bugs podem ser reportados e correções podem ser enviadas + para a Página do projeto + XonX na SourceForge. +#endif +
+
Este software é distribuído sob os termos da licença + MIT X11 / X Consortium e é provido, sem nenhuma garantia. Por favor + leia a Licença antes de começar a usar + o programa.
+ +

Uso

+

O XDarwin é uma X server "open-source" livremente + redistribuída do Sistema X Window. 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.

+

No modo Tela Cheia, quando o sistema X window está ativo, ele ocupa + a tela toda. Você pode voltar ao desktop do Mac OS X clicando Command-Option-A. + Essa combinação de teclas pode ser mudada nas preferências. + Pelo desktop Mac OS X, clique no ícone XDarwin no Dock para voltar ao + sistema X window. (Você pode mudar esse comportamento nas preferências + daí você deverá clicar no ícone XDarwin na janela + flutuante que aparecerá.)

+

No modo Compartilhado, o sistema X window e Aqua dividem a mesma tela. A janela + raiz da tela X11 está do tamanho da tela (monitor) e contém todas + as outras janelas. A janela raiz do X11 no modo compartilhado não é + mostrada pois o Aqua controla o fundo de tela.

+

Emulação de Mouse Multi-Botões

+

Muitas aplicações X11 insistem em usar um mouse de 3 botões. + Você pode emular um mouse de 3 botões com um simples botão, + mantendo pressionando teclas modificadoras enquanto você clica no botão + do mouse. Isto é controlado pela configuração da "Emulação + de Mouse Multi-Botões" da preferência "Geral". Por + padrão, a emulação está habilitada e mantendo pressionada + a tecla Command e clicando no botão do mouse ele simulará o clique + no segundo botão do mouse. Mantendo pressionada a tecla Option e clicando + no botão do mouse ele simulará o terceiro botão. Você + pode mudar a combinação de teclas modificadoras para emular os + botões dois e três nas preferências. Nota, se a tecla modificadora + foi mapeada para alguma outra tecla no xmodmap, você ainda terá + que usar a tecla atual especificada nas preferências para a emulação + do mouse multi-botões.

+

Ajustando seu Path

+

Seu path é a lista de diretórios a serem procurados por arquivos + executáveis. O comando X11 está localizado em /usr/X11R6/bin, + que precisa ser adicionado ao seu path. XDarwin faz isso para você por + padrão e pode-se também adicionar diretórios onde você + instalou aplicações de linha de comando.

+

Usuários experientes já terão configurado corretamente + seu path usando arquivos de inicialização de seu shell. Neste + caso, você pode informar o XDarwin para não modificar seu path + nas preferências. O XDarwin inicia o cliente inicial X11 no shell padrão + do usuário corrente. (Um shell alternativo pode ser também expecificado + nas preferências.) O modo para ajustar o path depende do shell que você + está usando. Isto é descrito na man page do seu shell.

+

Você pode também querer adicionar as man pages do X11 para + a lista de páginas a serem procuradas quando você está procurando + por documentação. As man pages do X11 estão localizadas + em /usr/X11R6/man e a variável de ambiente MANPATH + contém a lista de diretórios a buscar.

+

Preferências do Usuário

+

Várias opções podem ser ajustadas nas preferências + do usuário, acessível pelo item "Preferências..." + no menu "XDarwin". As opções listadas como opções + de inicialização, não terão efeito até você + reiniciar o XDarwin. Todas as outras opções terão efeito + imediatamente. Várias das opções estão descritas + abaixo:

+

Geral

+
    +
  • Usar o Beep do Sistema para o X11: Quando habilitado som de alerta + padrão do Mac OS X será usado como alerta no X11. Quando desabilitado + (padrão) um tom simples será usado.
  • +
  • Permitir o X11 mudar a aceleração do mouse: Por implementação + padrão no sistema X window, o gerenciador de janelas pode mudar a aceleração + do mouse. Isso pode gerar uma confusão pois a aceleração + do mouse pode ser ajustada diferentemente nas preferências do Mac OS + X e nas preferências do X window. Por padrão, o X11 não + está habilitado a mudar a aceleração do mouse para evitar + este problema.
  • +
  • Emulação de Mouse de Multi-Botões: Esta opção + está escrita acima em Uso. Quando a emulação + está habilitada as teclas modificadoras selecionadas tem que estar + pressionadas quando o botão do mouse for pressionado, para emular o + segundo e terceiro botões.
  • +
+

Inicial

+
    +
  • Modo Padrão: Se o usuário não indicar qual modo + de exibição quer usar (Tela Cheia ou Compartilhado) o modo especificado + aqui será usado .
  • +
  • Mostrar o painel de escolha na inicialização: Por + padrão, uma painel é mostrado quando o XDarwin é + iniciado para permitir que o usuário escolha ente o modo tela cheia + ou modo compartilhado. Se esta opção estiver desligada, o modo + padrão será inicializado automaticamente.
  • +
  • Número do Monitor X11: O X11 permite ser administrado em multiplos + monitores por servidores X separados num mesmo computador. O usuário + pode indicar o número do monitor para o XDarwin usar se mais de um + servidor X se estiver rodando simultaneamente.
  • +
  • Habilitar suporte a múltiplos monitores pelo Xinerama: o XDarwin + suporta múltiplos monitores com o Xinerama, que trata todos os monitores + como parte de uma grande e retangular tela. Você pode desabilitar o + Xinerama com está opção, mas normalmente o XDarwin não + controla múltiplos monitores corretamente sem está opção. + Se você só tiver um monotor, Xinerama é automaticamente + desabilitado.
  • +
  • Arquivo de Mapa de Teclado: O mapa de teclado é lido na inicialização + e traduzido para um mapa de teclado X11. Arquivos de mapa de teclado, estão + disponíveis numa grande variedade de línguas e são encontradas + em /System/Library/Keyboards.
  • +
  • Iniciando Clientes X11 primeiro: Quando o XDrawin é inicializado + pelo Finder, ele irá rodar o xinit para abrir o controlador + X window e outros clientes X. (Veja o manual "man xinit" para + mais informações.) Antes do XDarwin rodar o xinit + ele irá adicionar específicos diretórios a seu path. + Por padrão somente o /usr/X11R6/bin é adicionado. + separado por um ponto-e-vírgula. Os clientes X são inicializados + no shell padrão do usuário e os arquivos de inicialização + do shell serão lidos. Se desejado, um shell alternativo pode ser especificado.
  • +
+

Tela Cheia

+
    +
  • Botão de Combinação de Teclas: Clique no botão + e pressione qualquer quantidade de teclas modificadoras seguidas por uma tecla + padrão para modificar a combinação quando se quer mudar + entre o Aqua e X11.
  • +
  • Clique no Ícone no Dock para mudar para o X11: Habilitando + esta opção você irá ativar a mudança para + o X11 clicando no ícone do XDarwin no Dock. Em algumas versões + do Mac OS X, mudando pelo clique no Dock pode causar o desaparecimento do + cursor quando retornar ao Aqua.
  • +
  • Mostrar a Ajuda na inicialização: Isto irá mostrar + uma tela introdutória quando o XDarwin for inicializado no modo Tela + Cheia.
  • +
  • Profundidade de Cores em bits: No modo Tela Cheia, a tela do X11 + pode usar uma profundiadde de cor diferente da usada no Aqua. Se a opção + "Atual" está especificada, a profundidade usada pelo Aqua + quando o XDarwin iniciar será a mesma. Além das opções + 8, 15 ou 24 bits que podem ser especificadas.
  • +
+ +

Licença

+

A licença + principal nós por XDarwin baseada na licença tradicional MIT X11 + / X Consortium, que não impõe nenhuma condição sobre + modificações ou redistribuição do código-fonte + ou dos binários desde que o copyright/licença sejam mantidos intactos. + Para mais informações e notícias adicionais de copyright/licensing + em algumas seção do código, por favor refer to the source code.

+

Licença do X Consortium

+

Copyright (C) 1996 X Consortium

+

Permissões são em virtude garantidas, livre de mudanças, + para qualquer pessoa que possua uma cópia deste software e aos arquivos + de documentação associada (o "Software"), para lidar + com o software sem restrições, incluindo limitações + dos direitos de uso, cópia, modificação, inclusão, + publicação, distribuição, sub licença, e/ou + venda de cópias deste Software, e permitir pessoas to whom o Software + é fornecido para ser desta forma, verifique as seguintes condições:

+

O nota de copyright abaixo e a permissão deverão ser incluídas + em todas as cópias ou substanciais porções do Software.

+

O SOFTWARE 'E PROVIDO "COMO TAL", SEM GARANTIAS DE NENHUM TIPO, EXPLICITA + OU IMPLICITA, INCLUINDO MAS NÃO LIMITADO NOS AVISOS DE COMÉRCIO, + TAMANHO OU PARA PROPOSTAS PARTICULARES E NÃO INFRAÇÃO. + EM NENHUM ACONTECIMENTO O X CONSORTIUM SERÁ RESPONSAVÉL POR NENHUMA + RECLAMAÇÃO, DANOS OU OUTRAS RESPONSABILIDADES, SE NUMA AÇÃO + DE CONTRATO, OU OUTRA COISA, SURGINDO DE, FORA DE OU EM CONEXÃO COM O + SOFTWARE OU O USO OU OUTRO MODO DE LIDAR COM O SOFTWARE.

+

Exceto o contido nesta nota, o nome do X Consortium não pode ser usado + em propagandas ou outra forma de promoção de vendas, uso ou outro + modo de lidar com este Software sem ter recebido uma autorização + escrita pelo X Consortium.

+

O Sistema X Window é marca registrada do X Consortium, Inc.

+ + + 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 + +LinkSourceFile(InfoPlist.strings.cpp,../English.lproj) + +INCLUDES = -I$(SERVERSRC)/include + +#if defined (XorgVersionString) +VERS = XorgVersionString +PRE = XORG_VERSION_SNAP +NAME = "X Version 11" +LINK = 'X.Org Foundation' +#elif defined XFree86VersionString +VERS = XFree86VersionString +PRE = XF86_VERSION_SNAP +NAME = "XFree86" +LINK = 'XFree86 Project, Inc.' +#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) $@ + +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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/Localizable.strings 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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/objects.nib 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 @@ + + + + +XDarwin Ayuda + + +
+

XDarwin X Server for Mac OS X

+ X_VENDOR_NAME X_VERSION
+ Fecha de release: X_REL_DATE +
+

Contenido

+
    +
  1. Aviso Importante
  2. +
  3. Modo de uso
  4. +
  5. Configurando su Path
  6. +
  7. Preferencias del Usuario
  8. +
  9. Licencia
  10. +
+
+

Aviso Importante

+
+
+#if PRE_RELEASE +Esta es una versión pre-release de XDarwin, y no tiene ningún soporte. Patches y reportes de error pueden ser enviados a la página del proyecto XonX en SourceForge. Antes de reportar errores en versiones pre-release, por favor verifique la ultima versión en XonX o bien el X_VENDOR_LINK. +#else +Si el server el más antiguo que 6 a 12 meses, o si su hardware es posterior a la fecha indicada más arriba, por favor verifique la última versión antes de reportar problemas. Patches y reportes de error pueden ser enviados a la página del proyecto XonX en SourceForge. +#endif +
+
+Este software es distribuido bajo los términos de la Licencia MIT X11 / X Consortium y es provisto sin garantía alguna y en el estado en que se encuentra. Por favor lea la Licencia antes de utilizarlo.
+ +

Modo de uso

+

XDarwin es una X server open-source de distribución libre del X Window System. 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).

+

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ón de teclas puede cambiarse en las Preferencias de Usuario. Desde el Escritorio de Mac OS X, haga click en ícono 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.)

+

En modo rootless, el X window system comparte la pantalla con Aqua. La ventana root de X11 es del tamaño de la pantalla y contiene a todas las demás ventanas. La ventana root de X11 no se muestra en este modo, ya que Aqua maneja el fondo de pantalla.

+

Emulación de mouse multi-botón

+

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ón presionando teclas modificadoras mientras hace click. Esto es controlado en de la seccion "Emulación mouse" dentro de la sección "General" de las Preferencias del Usuario. Por defecto, la emulación está activa y utiliza la tecla Command para simular el 2do botón y la tecla Option para simlar el 3er botón. La conbinación para simular el 2do y 3er botón pueden ser modificada por cualquier combinación 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án siendo las utilizadas por la emulación de mouse multi-botón.

+ +

Configurando su Path

+

El path es la lista de directorios donde se buscarán los comandos ejecutables. Los comandos de X11 se encuentran en /usr/X11R6/bin, y éste necesita estar dentro de su path. XDarwin hace ésto automáticamente por defecto, y puede además agregar directorios adicionales donde tenga otros comandos de línea.

+

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á los clientes X11 iniciales usando el intérprete de comandos del usuario, según su configuración de login. Un intérprete de comandos alternativo puede ser especificado en las Preferencias del Usuario. La manera de configurar el path de su intérprete de comandos depende de cual está usando, y es generalmente descripta en las páginas man del mismo.

+

Además, Ud. puede agregar las páginas man de X11 a la lista de páginas que son consultadas. Estas están ubicadas en /usr/X11R6/man y MANPATH es la variable de entorno que contiene los directorios que son consultados.

+ +

Preferencias del Usuario

+

Ciertas opciones pueden definirse dentro de "Preferencias...", en el menú de XDarwin. Las opciones dentro de de "Inicio" no surtirán efecto hasta que la aplicación se reinicie. Las restantes opciones surten efecto inmediatamente. Las diferentes opciones se describen a continuación:

+

General

+
    +
  • Usar beep del sistema en X11: Cuando esta opción está activa, el sonido de alerta estándar de Mac OS X se usará como alerta de X11. Cuando está desactivada, un simple tono es utilizado (esta es la opción por defecto).
  • +
  • Permitir que X11 cambie la aceleración del mouse: En una implementación estándard de X11, el window manager puede cambiar la aceleración del mouse. Esto puede llevar a una gran confusión si la aceleración es diferente en XDarwin y en Mac OS X. Por defecto, no se le permite a X11 alterar la aceleración para evitar este inconveniente.
  • +
  • Emulación de mouse multi-botón: Esta opción es descripta más arriba bajo Modo de Uso. Cuando esta emulación está activa los modificadores seleccionados deben ser presionados cuando se hace click para emular el botón 2 o el botón 3.
  • +
+

Inicio

+
    +
  • Modo inicial: Si el usuario no indica si desea utilizar la Pantalla Completa o el modo Rootless, el modo especificado aquí será el usado.
  • +
  • Mostrar panel de selección al inicio: Por defecto, un diálogo permite al usuario elegir entre Pantalla Completa o Rootless al inicio. Si esta opción esta desactivada, XDarwin arrancará utilizando el modo por defecto sin consultar al usuario.
  • +
  • Número de display X11: X11 permite que existan múltiples pantallas manejadas por servidores X11 separados funcionando en una misma computadora. El usuario puede especificar aqui un número entero para indicar el número de pantalla (display) que XDarwin utilizará si más de un servidor X funciona en forma simultánea.
  • +
  • Habilitar soporte Xinerama para múltipes monitores: XDarwin suporta múltiple monitores con Xinerama, que maneja todos los monitores como si fueran parte de una gran pantalla rectangular. Puede deshabilitar Xinerama con esta opción, pero XDarwin no maneja múltiples monitores en forma correcta sin esta opción habilitada. Si tiene solo un monitor, Xinerama es automáticamente deshabilitado.
  • +
  • Archivo de mapa de teclado: Un archivo de mapa de teclas es leído al inicio y es traducido a un keymap X11 (un archivo estándard de X11 para especificar la función de cada tecla). Estos archivos, disponibles para una amplia variedad de lenguajes, pueden encontrarse en /System/Library/Keyboards.
  • +
  • Al iniciar clientes X11: Cuando XDarwin arranca desde el Finder, éste ejecutará xinit para a su vez arrancar el window manager y otros clientes. (Vea en "man xinit" para mayor información). Antes de ejecutar xinit XDarwin agregará los directorios especificados al path del usuario. Por defecto, solo /usr/X11R6/bin es agregado. Otros directorios adicionales puede agregarse separados por dos puntos (:). Los clientes X son ejecutados con el intérprete de comandos del usuario, por lo que los archivos de inicio de éste son leídos. Si se desea, un intérprete de comandos diferente puede ser especificado.
  • +
+

Pantalla Completa

+
    +
  • Botón para definir combinación de teclas: Haga click en este botón y luego presione cualquier combinación de modificadores seguidos de una tecla convencional para definir que combinación usará para intercambiar entre X11 y Aqua.
  • +
  • Click en el ícono del Dock cambia a X11: Habilite esta opción para volver a X11 al hacer click en ícono de XDarwin en el Dock. En algunas versiones de Mac OS X, al volver haciendo click en el Dock puede causar al desaparción del cursor al volver a Aqua.
  • +
  • Mostrar ayuda al inicio: Esta opción habilitada hará que una pantalla inicial de introducción aparezca cuando XDarwin es arrancado en modo Pantalla Completa.
  • +
  • Profundidad de color (bits): 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á adoptada por X11. Al contrario, puede especificar 8, 15, o 24 bits.
  • +
+ +

Licencia

+La licencia principal de XDarwin es basada en la Licencia MIT X11 tradicional, que no impone condiciones a la modificación o redistribución del código fuente o de archivos binarios más allá de requerir que los mensajes de Licencia y Copyright se mantengan intactos. Para mayor información y para mensajes adicionales de Licencia y Copyright que cubren algunas secciones del código fuente, por favor consulte the source code. +

Licencia del X Consortium

+

Copyright (C) 1996 X Consortium

+

Se otorga aqui permiso, libre de costo, a toda persona que obtenga una copia de este Software y los archivos de documentación asociados (el "Software"), +para utilizar el Software sin restricciones, incluyendo sin límites 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:

+

El mensaje de Copyright indicado más arriba y este permiso será incluído en todas las copias o porciones sustanciales del Software.

+

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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.

+

Excepto lo indicado en este mensaje, el nombre del X Consortium no será utilizado en propaganda o como medio de promoción para la venta, utilización u otros manejos de este Software sin previa autorización escrita del X Consortium.

+

X Window System es una marca registrada de X Consortium, Inc.

+

X Consortium License (English)

+

Copyright (C) 1996 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.

+

X Window System is a trademark of X Consortium, Inc.

+ + 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 + +LinkSourceFile(InfoPlist.strings.cpp,../English.lproj) + +INCLUDES = -I$(SERVERSRC)/include + +#if defined (XorgVersionString) +VERS = XorgVersionString +PRE = XORG_VERSION_SNAP +NAME = "X Version 11" +LINK = 'X.Org Foundation' +#elif defined XFree86VersionString +VERS = XFree86VersionString +PRE = XF86_VERSION_SNAP +NAME = "XFree86" +LINK = 'XFree86 Project, Inc.' +#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) $@ + +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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/Localizable.strings 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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/objects.nib 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 @@ + + + + +XDarwin Help + + +
+

XDarwin X Server for Mac OS X

+ X_VENDOR_NAME X_VERSION
+ Färdigställt: X_REL_DATE +
+

Innehåll

+
    +
  1. Viktigt!
  2. +
  3. Användande
  4. +
  5. Att ställa in sin sökväg
  6. +
  7. Inställningar
  8. +
  9. Licens
  10. +
+
+

Viktigt!

+
+
+#if PRE_RELEASE +Detta är en testversion av XDarwin, och du kan inte garranteras någon som helst support för den. Buggar och fel kan rapporteras och förslag till fixar kan skickas till XonX-projektets sida på SourceForge. Innan du rapporterar buggar i testversioner, var god pröva den senaste versionen från XonX eller i X_VENDOR_LINK. +#else +Om servern är äldre än 6-12 månader, eller om din hårdvara är nyare än datumet ovan, leta efter en nyare version innan du rapporterar fel. Buggar och fel kan rapporteras och förslag till fixar kan skickas till XonX-projektets sida på SourceForge. +#endif +
+
+Denna programvara distrubueras i enlighet med MIT X11 / X Consortium License och tilhandhålls som den är, helt utan garantier. Var god läs igenom licensdokumentet (engelska) innan du använder programmet.
+ +

Användande

+

XDarwin är en fritt spridd X server av X Window-systemet. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin kan köras på Mac OS X i fullskärmsläge eller rotlöst läge.

+

I fullskärmsläge kommer X window-systemet att ta över hela skärmen när det är aktivt. Du kan byta tillbaka till Mac OS Xs skrivbord genom att trycka Kommando-Alt-A. Denna tangentkombination kan ändra i inställningarna. När du är på Mac OS Xs skrivbord kan du klicka på XDarwin-ikonen i dockan för att byta tillbaka till X Window-systemet. (Du kan förändra detta beteende i inställningarna så att du istället måste klicka i det fltande bytesfönstret istället.)

+

I rotlöstläge delar X11 och Aqua på din skärm. Rotfönstret på X11-skärmen är av samma storlek som hela skärmen och innehåller alla andra fönster - det fungerar som bakgrund. I rotlöstläge visas inte detta rotfönster, eftersom Aqua hanterar skrvbordbakgrunden.

+ +

Emulering av flerknapparsmus

+

Många X11-program utnyttjar en treknapparsmus. Du kan emulera en treknapparsmus med en knapp genom att hålla ner olika knappar på tangentbordet medan du klickar med musens enda knapp. Denna funktion styrs av inställningarna i "Emulera flerknapparsmus" under fliken "Diverse" i inställningarna. Grundinställningen är att emulationen är aktiv och att ett kommando-klick (Håll ner kommando och klicka) simulerar den andra musknappen. Den tredje musknappen fås genom att hålla ner alt och klicka. Du kan ändra detta till någon annan kombination av de fem tangenterna kommando, alt, kontrol, skift och fn (Powerbook/iBook). Notera att om dessa knappar har flyttats med hjälp av kommandot xmodmap kommer denna förändring inte att påverka vilka knappar som används vid flerknappsemulationen.

+ +

Att ställa in sin sökväg

+

Din sökväg är en lista av kataloger som söks igenom när terminalen letar efter kommandon att exekvera. Kommandon som hör till X11 ligger i /usr/X11R6/bin, en katalog som inte ligger i din sökväg från början. XDarwin lägger till denna katalog åt dig, och du kan också lägga till ytterligare kataloger i vilka du lagt program som skall köras från kommandoraden.

+

Mer erfarna användare har antagligen redan ställt in sin sökväg i skalets inställningsfiler. Om detta gäller dig kan ställa in XDarwin så att din sökväg inte modifieras. XDarwin startar de första X11-klienterna i användarens inloggningsskal (Vill du använda ett alternativt skall, kan du specificera detta i inställningarna). Hur du ställer in din sökväg beror på vilket skal du använder. Exakt hur beskrivs i skalets man-sidor.

+ +

Utöver detta kan du också vilja lägga till X11s man-sidor (dokumentation) till listan äver sidor som som skall sökas när du vill läsa efter dokumentationen. X11s man-sidor ligger i /usr/X11R6/man och listan äver kataloger att söka bestämms av variabelnMANPATH.

+ +

Inställningar

+

I inställningarna finns ett antal alternativ där du kan påverka hur XDarwin beter sig i vissa fall. Inställningarna kommer du till genom att välja "Inställningar..." i menyn "XDarwin". De alternativ som finns under fliken "Starta" träder inte i kraft förrän du startat om programmet. Alla andra alternativ träder i kraft omedelbart. De olika alternativen beskrivs nedan:

+

Diverse

+
    +
  • Använd Mac OS varningsljud i X11: När detta alternativ är valt används Mac OS vanliga varningsljud är X11s varningsljud (bell). När detta alternativ inte är valt (förvalt) används en vanlig ton.
  • +
  • Tillåt X11 att ändra musens acceleration: I ett vanligt X11-system kan fönsterhanteraren ändra musens acceleration. Detta kan vara förvirrande eftersom musens acceleration kan vara olika i Mac OS Xs System Preferences och i fönsterhanteraren i X11. Förvalet är att X11 inte kan ändra musens acceleration för att på detta sätt undvika detta problem.
  • +
  • Emulera flerknapparsmus: Detta beskrivs ovan under Användande. När emulationen är aktiv måste du hålla ner de valda knapparna för att emulera en andra eller tredje musknapp.
  • +
+

Starta

+
    +
  • Förvalt läge: Om användaren inte på annat sätt väljer vilket läge som skall användas kommer alternativet här att användas.
  • +
  • Visa val av skärmläge vid start: Förvalet är att visa ett fönster när XDarwin startar som låter användaren välja mellan fullskärmsläge och rotlöst läge. Om detta alternativ inte är aktivt kommer XDarwin automatiskt att startas i det läge som valts ovan.
  • +
  • Skärmnummer i X11: X11 tillåter att det finns flera skärmar styrda av varsin X-server på en och samma dator. Användaren kan ange vilket nummer XDarwin skall använda om mer än en X-server skall användas samtidigt.
  • +
  • Aktivera Xinerama (stöd för flera skärmar): XDarwin stödjer flera skärmar genom Xinerama, vilket hanterar alla skrämar som delar av en enda stor rektangulär skärm. Du kan använda detta alternativ för att stänga av Xinerama, men för närvarande kan inte XDarwin hantera flera skärmar utan det. Om du bara har en skärm kommer Xinerama automatiskt att deaktiveras.
  • +
  • Fil med tangentbordsuppsättning: En fil som anger tangentbordsuppsättning läses vid start och översätts till en tangentborsuppsättningsfil för X11. Filer med tangentbordsuppsättningar för ett stort antal språk finns i /System/Library/Keyboards.
  • +
  • Startar första X11-klienterna: När X11 startas från Finder kommer det att exekvera filen xinit för att starta fönsterhanteraren i X11 och andra program. (Se "man xinit" för mer information.) Innan XDarwin kör xinit kommer det att lägga till katalogern här till användarens sökväg. Förvalet är att endast lägga till katalogen /usr/X11R6/bin. Ytterligare kataloger kan läggas till - separera dem med kolon. X11-klienterna startas i användarens inloggningsskal så att användarens inställningsfiler i skalet läses. Om så önskas kan de startas i ett annat skal.
  • +
+

Fullskärm

+
    +
  • Tangentkombinationsknappen: Tryck på denna knapp och en tangentkombination för att ändra den tangentkombination som används för att byta mellan X11 och Aqua.
  • +
  • Klick på ikonen i dockan byter till X11: Aktivera detta alternativ för att byta till X11 genom att klicka på ikonen i dockan. I vissa versioner av Mac OS X kommer ett bte på detta sätt att gömma pekaren när du återvänder till Aqua.
  • +
  • Visa fullskärmshjälp vid start: Detta kommer att visa en informationsruta när XDarwin startas i fullskärmsläge.
  • +
  • Färgdjup: I fullskärmsläge kan X11 använda ett annat färgdjup än Aquas. Om du väjer "Nuvarande" kommer X11 att använda det färgdjup som Aqua har just då. Annars kan du välja 8, 15, eller 24 bitare färg.
  • +
+ +

Licens (svenska)

+

Den huvudsakliga licens vi använder oss av är baserad på den traditionella MIT X11 / XConsortium-licensen, vilken inte på något sätt begränsar förändringar eller vidarespridning av vare sig källkod eller kompilerad programvara annat än genom att kräva att delarna som rör copyright och licensiering lämnas intakta. För mer information och ytterligare copyright/licensieringsinfromation rörande vissa speciella delar av koden, se the source code.

+ +

Licence (english)

+

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.

+ +

X Consortium License

+

Copyright (C) 1996 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.

+

X Window System is a trademark of X Consortium, Inc.

+ + 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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/XDarwin.icns 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 + +LinkSourceFile(InfoPlist.strings.cpp,../English.lproj) + +INCLUDES = -I$(SERVERSRC)/include + +#if defined (XorgVersionString) +VERS = XorgVersionString +PRE = XORG_VERSION_SNAP +NAME = "X Version 11" +LINK = 'X.Org Foundation' +#elif defined XFree86VersionString +VERS = XFree86VersionString +PRE = XF86_VERSION_SNAP +NAME = "XFree86" +LINK = 'XFree86 Project, Inc.' +#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) $@ + +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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/Localizable.strings 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 Binary files /dev/null and b/nx-X11/programs/Xserver/hw/darwin/bundle/ko.lproj/MainMenu.nib/objects.nib 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 @@ + + + + +XDarwin Help + + +
+

XDarwin X Server for Mac OS X

+ X_VENDOR_NAME X_VERSION
+ Release Date: X_REL_DATE +
+

Contents

+
    +
  1. Important Notice
  2. +
  3. Usage
  4. +
  5. Setting Your Path
  6. +
  7. User Preferences
  8. +
  9. License
  10. +
+
+

Important Notice

+
+
+#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 XonX project page at SourceForge. Before reporting bugs in pre-release versions, please check the latest version from XonX 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 XonX project page at SourceForge. +#endif +
+
+This software is distributed under the terms of the MIT X11 / X Consortium License and is provided AS IS, with no warranty. Please read the License before using.
+ +

Usage

+

XDarwin is a freely redistributable open-source X server for the X Window System. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin runs on Mac OS X in full screen or rootless modes.

+

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

+

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.

+

Multi-Button Mouse Emulation

+

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.

+ +

Setting Your Path

+

Your path is the list of directories to be searched for executable commands. The X11 commands are located in /usr/X11R6/bin, 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.

+

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.

+

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 /usr/X11R6/man and the MANPATH environment variable contains the list of directories to search.

+ +

User Preferences

+

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:

+

General

+
    +
  • Use System beep for X11: When enabled the standard Mac OS X alert sound is used as the X11 bell. When disabled (default) a simple tone is used.
  • +
  • Allow X11 to change mouse acceleration: 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.
  • +
  • Multi-Button Mouse Emulation: This is described above under Usage. 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.
  • +
+

Start Up

+
    +
  • Default Mode: If the user does not indicate whether to run in full screen or rootless mode, the mode specified here will be used.
  • +
  • Show mode pick panel on startup: 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.
  • +
  • X11 Display number: 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.
  • +
  • Allow Xinerama multiple monitor support: 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.
  • +
  • Keymapping File: 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 /System/Library/Keyboards.
  • +
  • Starting First X11 Clients: When XDarwin is started from the Finder, it will run xinit to launch the X window manager and other X clients. (See "man xinit" for more information.) Before XDarwin runs xinit it will add the specified directories to the user's path. By default only /usr/X11R6/bin 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.
  • +
+

Full Screen

+
    +
  • Key combination button: 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.
  • +
  • Click on icon in Dock switches to X11: 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.
  • +
  • Show help on startup: This will show an introductory splash screen when XDarwin is started in full screen mode.
  • +
  • Color bit depth: 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.
  • +
+ +

License

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

X Consortium License

+

Copyright (C) 1996 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.

+

X Window System is a trademark of X Consortium, Inc.

+ + 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 +#include +#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 +# include +# include "exevents.h" +# include "extinit.h" +#endif + +#include +#include +#include +#include +#include +#include + +#define HAS_UTSNAME 1 +#include + +#define NO_CFPLUGIN +#include +#include +#include + +#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<offsetRed; + visual->greenMask = ((1<offsetGreen; + visual->blueMask = ((1<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 : fake middle mouse button with modifier keys.\n"); + ErrorF("-fakemouse3 : fake right mouse button with modifier keys.\n"); + ErrorF(" ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n"); + ErrorF("-keymap : 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 : use a screen resolution of x .\n"); + ErrorF("-depth <8,15,24> : use this bit depth.\n"); + ErrorF("-refresh : use a monitor refresh rate of 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 +#include "inputstr.h" +#include "scrnintstr.h" +#include + +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 +#include +#include +#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 +#include +#include +#include + +/* 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 +// 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 +#include +#include +#include +#include +#include +#include // 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 +#include +#include "inputstr.h" +#include +#include +#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 + +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 +#include +#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 +#include +#include +#include +#include + +#include + +#define NO_CFPLUGIN +#include +#include +#include +#include + +// 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 +#include +#include +#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 +#include +#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 +#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 + +@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 // 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 + +#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 = ""; + }; + 0127909600074AF60A000002 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = XApplication.m; + refType = 4; + sourceTree = ""; + }; + 0127909800074B1A0A000002 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = XApplication.h; + refType = 4; + sourceTree = ""; + }; + 015698ED003DF345CE6F79C2 = { + isa = PBXFileReference; + lastKnownFileType = image.icns; + path = XDarwin.icns; + refType = 4; + sourceTree = ""; + }; + 0157A37D002CF6D7CE6F79C2 = { + children = ( + F533214601A4B45401000001, + 0157A37E002CF6D7CE6F79C2, + F58D65DF018F79B101000001, + F533213D0193CBE001000001, + 43B962E200617B93416877C2, + F5ACD263C5BE031F01000001, + F51BF62E02026E3501000001, + F5ACD25CC5B5E96601000001, + F587E16401924C6901000001, + ); + isa = PBXVariantGroup; + name = Credits.rtf; + path = ""; + refType = 4; + sourceTree = ""; + }; + 0157A37E002CF6D7CE6F79C2 = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = English; + path = English.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + 015EDCEA004203A8CE6F79C2 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = IOKit.framework; + path = /System/Library/Frameworks/IOKit.framework; + refType = 0; + sourceTree = ""; + }; + 018F40F2003E1902CE6F79C2 = { + children = ( + 018F40F3003E1916CE6F79C2, + 021D6BA9003E1BACCE6F79C2, + 3E74E03600863F047F000001, + F5A94EF10314BAC70100011B, + 018F40F6003E1974CE6F79C2, + 6E5F5F0005537A1A008FEAD7, + ); + isa = PBXGroup; + name = "X Server"; + path = ..; + refType = 4; + sourceTree = ""; + }; + 018F40F3003E1916CE6F79C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = darwin.c; + refType = 4; + sourceTree = ""; + }; + 018F40F6003E1974CE6F79C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = darwinKeyboard.c; + refType = 4; + sourceTree = ""; + }; + 018F40F8003E1979CE6F79C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = quartz.c; + refType = 4; + sourceTree = ""; + }; + 018F40FA003E197ECE6F79C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = quartz.h; + refType = 4; + sourceTree = ""; + }; + 018F40FC003E1983CE6F79C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = xfIOKit.c; + refType = 4; + sourceTree = ""; + }; + 018F40FE003E1988CE6F79C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = xfIOKit.h; + refType = 4; + sourceTree = ""; + }; + 018F4100003E19E4CE6F79C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = xfIOKitCursor.c; + refType = 4; + sourceTree = ""; + }; +//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 = ""; + }; + 02A1FEA6006D34BE416877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = xfIOKitStartup.c; + refType = 4; + sourceTree = ""; + }; + 02A1FEA8006D38F0416877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = quartzStartup.c; + refType = 4; + sourceTree = ""; + }; + 02E03CA000348209CE6F79C2 = { + children = ( + F533214701A4B48301000001, + 02E03CA100348209CE6F79C2, + F58D65E0018F79C001000001, + F533213E0193CBF401000001, + 43B962E300617B93416877C2, + F5ACD268C5BE046401000001, + F51BF62F02026E5C01000001, + F5ACD261C5B5EA2001000001, + F587E16501924C7401000001, + ); + isa = PBXVariantGroup; + name = XDarwinHelp.html; + path = ""; + refType = 4; + sourceTree = ""; + }; + 02E03CA100348209CE6F79C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.html; + name = English; + path = English.lproj/XDarwinHelp.html; + refType = 4; + sourceTree = ""; + }; +//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 = ""; + }; +//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 = ""; + }; + 04329611000763920A000002 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = Preferences.h; + refType = 4; + sourceTree = ""; + }; +//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 = ""; + }; + 089C165CFE840E0CC02AAC07 = { + children = ( + F533214301A4B3F001000001, + 089C165DFE840E0CC02AAC07, + F58D65DD018F798F01000001, + F533213A0193CBA201000001, + 43B962E100617B49416877C2, + F5ACD269C5BE049301000001, + F51BF62B02026DDA01000001, + F5ACD262C5B5EA4D01000001, + F587E16101924C2F01000001, + ); + isa = PBXVariantGroup; + name = InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + 089C165DFE840E0CC02AAC07 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = English; + path = English.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; +//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 = " + + + + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + x11app + + CFBundleTypeName + X11 Application + CFBundleTypeOSTypes + + **** + + CFBundleTypeRole + Viewer + + + CFBundleTypeExtensions + + tool + * + + CFBundleTypeName + UNIX Application + CFBundleTypeOSTypes + + **** + + CFBundleTypeRole + Viewer + + + CFBundleExecutable + XDarwin + CFBundleGetInfoString + XDarwin 1.4.0, X.Org Foundation + CFBundleIconFile + XDarwin.icns + CFBundleIdentifier + org.xfree86.XDarwin + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + XDarwin + CFBundlePackageType + APPL + CFBundleShortVersionString + XDarwin 1.4.0 + CFBundleSignature + ???? + CFBundleVersion + + NSHelpFile + XDarwinHelp.html + NSMainNibFile + MainMenu + NSPrincipalClass + XApplication + + +"; + }; + 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 = ""; + }; + 1058C7A1FEA54F0111CA2CBB = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = Cocoa.framework; + path = /System/Library/Frameworks/Cocoa.framework; + refType = 0; + sourceTree = ""; + }; + 1058C7A2FEA54F0111CA2CBB = { + children = ( + 29B97325FDCFA39411CA2CEA, + 29B97324FDCFA39411CA2CEA, + ); + isa = PBXGroup; + name = "Other Frameworks"; + refType = 4; + sourceTree = ""; + }; +//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 = ""; + }; + 1220774400712D2D416877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = English; + path = English.lproj/Localizable.strings; + refType = 4; + sourceTree = ""; + }; + 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 = ""; + }; +//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 = ""; + }; + 170DFB0000729C86416877C2 = { + children = ( + 018F40FC003E1983CE6F79C2, + 018F40FE003E1988CE6F79C2, + 018F4100003E19E4CE6F79C2, + 02A1FEA6006D34BE416877C2, + ); + isa = PBXGroup; + name = IOKit; + path = ../iokit; + refType = 4; + sourceTree = ""; + }; +//170 +//171 +//172 +//173 +//174 +//190 +//191 +//192 +//193 +//194 + 19C28FACFE9D520D11CA2CBB = { + children = ( + 0A79E19E004499A1CE6F79C2, + 6EF7C58703D3BC6D00000104, + 6EF065C603D4EE19006877C2, + 6E11A985048BDFEE006877C2, + 6E7904100500F05600EEC080, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = ""; + }; +//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 = ""; + }; + 1BD8DE4300B8A3567F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = English; + path = English.lproj/InfoPlist.strings.cpp; + refType = 4; + sourceTree = ""; + }; + 1BD8DE4400B8A38E7F000001 = { + children = ( + F533214801A4B4D701000001, + 1BD8DE4500B8A38E7F000001, + F58D65E1018F79E001000001, + F533213F0193CC2501000001, + 1BD8DE4800B8A4167F000001, + F5ACD267C5BE03FC01000001, + F51BF63002026E8D01000001, + F5ACD260C5B5E9DF01000001, + F587E16601924C9D01000001, + ); + isa = PBXVariantGroup; + name = XDarwinHelp.html.cpp; + path = ""; + refType = 4; + sourceTree = ""; + }; + 1BD8DE4500B8A38E7F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = English; + path = English.lproj/XDarwinHelp.html.cpp; + refType = 4; + sourceTree = ""; + }; + 1BD8DE4700B8A3C77F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Japanese; + path = Japanese.lproj/InfoPlist.strings.cpp; + refType = 4; + sourceTree = ""; + }; + 1BD8DE4800B8A4167F000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Japanese; + path = Japanese.lproj/XDarwinHelp.html.cpp; + refType = 4; + sourceTree = ""; + }; + 1BE4F84D0006C9890A000002 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = Carbon.framework; + path = /System/Library/Frameworks/Carbon.framework; + refType = 0; + sourceTree = ""; + }; +//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 = ""; + }; +//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 = ""; + }; + 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 = ""; + }; +//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 = ""; + }; + 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 = ""; + }; + 29B97318FDCFA39411CA2CEA = { + children = ( + F533214201A4B3CE01000001, + 29B97319FDCFA39411CA2CEA, + F58D65DB018F793801000001, + F53321390193CB6A01000001, + 43B962E000617B49416877C2, + F5ACD265C5BE038601000001, + F51BF62A02026DAF01000001, + F5ACD25EC5B5E98D01000001, + F587E16001924C1D01000001, + ); + isa = PBXVariantGroup; + name = MainMenu.nib; + path = ""; + refType = 4; + sourceTree = ""; + }; + 29B97319FDCFA39411CA2CEA = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = English; + path = English.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA = { + children = ( + 1058C7A0FEA54F0111CA2CBB, + 1058C7A2FEA54F0111CA2CBB, + ); + isa = PBXGroup; + name = Frameworks; + path = ""; + refType = 4; + sourceTree = ""; + }; + 29B97324FDCFA39411CA2CEA = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = AppKit.framework; + path = /System/Library/Frameworks/AppKit.framework; + refType = 0; + sourceTree = ""; + }; + 29B97325FDCFA39411CA2CEA = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = Foundation.framework; + path = /System/Library/Frameworks/Foundation.framework; + refType = 0; + sourceTree = ""; + }; +//290 +//291 +//292 +//293 +//294 +//320 +//321 +//322 +//323 +//324 + 32FEE13C00E07C3E7F000001 = { + children = ( + F5269C2D01D5BC3501000001, + F5269C2E01D5BC3501000001, + ); + isa = PBXGroup; + name = "Old Cocoa Imp"; + path = ""; + refType = 4; + sourceTree = ""; + }; +//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 = ""; + }; +//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 = ""; + }; +//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 = ""; + }; + 43B962CF00617089416877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = quartzCocoa.m; + refType = 4; + sourceTree = ""; + }; + 43B962D000617089416877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = quartzPasteboard.c; + refType = 4; + sourceTree = ""; + }; + 43B962D100617089416877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = quartzPasteboard.h; + refType = 4; + sourceTree = ""; + }; + 43B962E000617B49416877C2 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = Japanese; + path = Japanese.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + 43B962E100617B49416877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = Japanese; + path = Japanese.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + 43B962E200617B93416877C2 = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = Japanese; + path = Japanese.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + 43B962E300617B93416877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.html; + name = Japanese; + path = Japanese.lproj/XDarwinHelp.html; + refType = 4; + sourceTree = ""; + }; +//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 = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + glxCGL + CFBundleGetInfoString + + CFBundleIconFile + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + GLX bundle using Apple's OpenGL + CFBundlePackageType + BNDL + CFBundleShortVersionString + 0.1 + CFBundleSignature + ???? + CFBundleVersion + 0.1 + + +"; + }; + 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 = ""; + }; + 6E5F5F0105537A5F008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = quartzKeyboard.c; + refType = 4; + sourceTree = ""; + }; + 6E5F5F030553815A008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = keysym2ucs.c; + refType = 4; + sourceTree = ""; + }; + 6E5F5F040553815A008FEAD7 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = keysym2ucs.h; + refType = 4; + sourceTree = ""; + }; + 6E6656EC048832CF006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = "x-hook.c"; + refType = 4; + sourceTree = ""; + }; + 6E6656ED048832CF006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = "x-hook.h"; + refType = 4; + sourceTree = ""; + }; + 6E6656F0048832EC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = dri.c; + refType = 4; + sourceTree = ""; + }; + 6E6656F1048832EC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = dri.h; + refType = 4; + sourceTree = ""; + }; + 6E6656F2048832EC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = dristruct.h; + refType = 4; + sourceTree = ""; + }; + 6E6656F3048832F9006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = appledri.c; + refType = 4; + sourceTree = ""; + }; + 6E79040104FD5ED900EEC080 = { + children = ( + 6E79040204FD5EDA00EEC080, + 6E79040304FD5EDA00EEC080, + 6E79040404FD5EDA00EEC080, + ); + isa = PBXGroup; + name = "Safe Alpha"; + path = safeAlpha; + refType = 4; + sourceTree = ""; + }; + 6E79040204FD5EDA00EEC080 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = safeAlpha.h; + refType = 4; + sourceTree = ""; + }; + 6E79040304FD5EDA00EEC080 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = safeAlphaPicture.c; + refType = 4; + sourceTree = ""; + }; + 6E79040404FD5EDA00EEC080 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = safeAlphaWindow.c; + refType = 4; + sourceTree = ""; + }; + 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 = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + xpr + CFBundleGetInfoString + + CFBundleIconFile + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Xplugin rootless implementation + CFBundlePackageType + BNDL + CFBundleShortVersionString + 0.1 + CFBundleSignature + ???? + CFBundleVersion + 0.1 + + +"; + }; + 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 = ""; + }; + 6E97A0F305079B6500B8294C = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = crAppleWM.m; + refType = 4; + sourceTree = ""; + }; + 6E97A0F505079F9100B8294C = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = applewmExt.h; + refType = 4; + sourceTree = ""; + }; + 6EA0B3AF0544A9CC006877C2 = { + children = ( + 6EA0B3B00544A9CC006877C2, + 6EA0B3B10544A9CC006877C2, + 6EA0B3B20544A9CC006877C2, + 6EA0B3B30544A9CC006877C2, + 6EA0B3B40544A9CC006877C2, + 6EA0B3B50544A9CC006877C2, + 6EA0B3B60544A9CC006877C2, + 6EA0B3B70544A9CC006877C2, + ); + isa = PBXGroup; + name = Acceleration; + path = accel; + refType = 4; + sourceTree = ""; + }; + 6EA0B3B00544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = rlAccel.h; + refType = 4; + sourceTree = ""; + }; + 6EA0B3B10544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rlBlt.c; + refType = 4; + sourceTree = ""; + }; + 6EA0B3B20544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rlCopy.c; + refType = 4; + sourceTree = ""; + }; + 6EA0B3B30544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rlFill.c; + refType = 4; + sourceTree = ""; + }; + 6EA0B3B40544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rlFillRect.c; + refType = 4; + sourceTree = ""; + }; + 6EA0B3B50544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rlFillSpans.c; + refType = 4; + sourceTree = ""; + }; + 6EA0B3B60544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rlGlyph.c; + refType = 4; + sourceTree = ""; + }; + 6EA0B3B70544A9CC006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rlSolid.c; + refType = 4; + sourceTree = ""; + }; + 6EA8EEC80445E25C006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = rootlessConfig.h; + refType = 4; + sourceTree = ""; + }; + 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 = ""; + }; + 6EC4A65E042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rootlessCommon.c; + refType = 4; + sourceTree = ""; + }; + 6EC4A65F042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = rootlessCommon.h; + refType = 4; + sourceTree = ""; + }; + 6EC4A660042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = rootlessWindow.h; + refType = 4; + sourceTree = ""; + }; + 6EC4A661042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rootlessScreen.c; + refType = 4; + sourceTree = ""; + }; + 6EC4A662042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rootlessWindow.c; + refType = 4; + sourceTree = ""; + }; + 6EC4A663042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rootlessGC.c; + refType = 4; + sourceTree = ""; + }; + 6EC4A664042A9654006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = rootlessValTree.c; + refType = 4; + sourceTree = ""; + }; + 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 = ""; + }; + 6ECF218404589E4D006877C2 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = xpr.h; + refType = 4; + sourceTree = ""; + }; + 6ECF218604589F40006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = xprCursor.c; + refType = 4; + sourceTree = ""; + }; + 6EDDB2DF04508B2C006877C2 = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = xprScreen.c; + refType = 4; + sourceTree = ""; + }; + 6EE1214104968658006877C2 = { + children = ( + 6EE1214304968692006877C2, + 6EE1214404968692006877C2, + 6EE1214204968692006877C2, + 6E97A0F305079B6500B8294C, + 6EE1214504968692006877C2, + 6EE1214604968692006877C2, + ); + isa = PBXGroup; + path = cr; + refType = 4; + sourceTree = ""; + }; + 6EE1214204968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = cr.h; + refType = 4; + sourceTree = ""; + }; + 6EE1214304968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = XView.m; + refType = 4; + sourceTree = ""; + }; + 6EE1214404968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = XView.h; + refType = 4; + sourceTree = ""; + }; + 6EE1214504968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = crFrame.m; + refType = 4; + sourceTree = ""; + }; + 6EE1214604968692006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = crScreen.m; + refType = 4; + sourceTree = ""; + }; + 6EE9B21604E859C200CA7FEA = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = applewm.c; + refType = 4; + sourceTree = ""; + }; + 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 = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + glxMesa + CFBundleGetInfoString + + CFBundleIconFile + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + GLX bundle with Mesa + CFBundlePackageType + BNDL + CFBundleShortVersionString + 0.1 + CFBundleSignature + ???? + CFBundleVersion + 0.1 + + +"; + }; + 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 = ""; + }; + 6EF471A004478DE0006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = Xplugin.h; + refType = 4; + sourceTree = ""; + }; + 6EF471A204479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = "x-hash.c"; + refType = 4; + sourceTree = ""; + }; + 6EF471A304479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = "x-list.h"; + refType = 4; + sourceTree = ""; + }; + 6EF471A404479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = "x-hash.h"; + refType = 4; + sourceTree = ""; + }; + 6EF471A504479263006877C2 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = "x-list.c"; + refType = 4; + sourceTree = ""; + }; + 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 = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + glxAGL + CFBundleGetInfoString + + CFBundleIconFile + + CFBundleIdentifier + + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + GLX bundle using AGL framework + CFBundlePackageType + BNDL + CFBundleShortVersionString + 0.1 + CFBundleSignature + ???? + CFBundleVersion + 0.1 + + +"; + }; + 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 = ""; + }; + F51BF62B02026DDA01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = Portuguese; + path = Portuguese.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + F51BF62C02026E0601000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Portuguese; + path = Portuguese.lproj/InfoPlist.strings.cpp; + refType = 4; + sourceTree = ""; + }; + F51BF62D02026E1C01000001 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = Portuguese; + path = Portuguese.lproj/Localizable.strings; + refType = 4; + sourceTree = ""; + }; + F51BF62E02026E3501000001 = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = Portuguese; + path = Portuguese.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + F51BF62F02026E5C01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.html; + name = Portuguese; + path = Portuguese.lproj/XDarwinHelp.html; + refType = 4; + sourceTree = ""; + }; + F51BF63002026E8D01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Portuguese; + path = Portuguese.lproj/XDarwinHelp.html.cpp; + refType = 4; + sourceTree = ""; + }; + F5269C2D01D5BC3501000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = pseudoramiX.c; + refType = 4; + sourceTree = ""; + }; + F5269C2E01D5BC3501000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = pseudoramiX.h; + refType = 4; + sourceTree = ""; + }; + F53321390193CB6A01000001 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = German; + path = German.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + F533213A0193CBA201000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = German; + path = German.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + F533213B0193CBB401000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = German; + path = German.lproj/InfoPlist.strings.cpp; + refType = 4; + sourceTree = ""; + }; + F533213C0193CBC901000001 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = German; + path = German.lproj/Localizable.strings; + refType = 4; + sourceTree = ""; + }; + F533213D0193CBE001000001 = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = German; + path = German.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + F533213E0193CBF401000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.html; + name = German; + path = German.lproj/XDarwinHelp.html; + refType = 4; + sourceTree = ""; + }; + F533213F0193CC2501000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = German; + path = German.lproj/XDarwinHelp.html.cpp; + refType = 4; + sourceTree = ""; + }; + F53321400193CCF001000001 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = ApplicationServices.framework; + path = /System/Library/Frameworks/ApplicationServices.framework; + refType = 0; + sourceTree = ""; + }; + F53321410193CCF001000001 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = CoreAudio.framework; + path = /System/Library/Frameworks/CoreAudio.framework; + refType = 0; + sourceTree = ""; + }; + F533214201A4B3CE01000001 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = Dutch; + path = Dutch.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + F533214301A4B3F001000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = Dutch; + path = Dutch.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + F533214401A4B40F01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Dutch; + path = Dutch.lproj/InfoPlist.strings.cpp; + refType = 4; + sourceTree = ""; + }; + F533214501A4B42501000001 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = Dutch; + path = Dutch.lproj/Localizable.strings; + refType = 4; + sourceTree = ""; + }; + F533214601A4B45401000001 = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = Dutch; + path = Dutch.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + F533214701A4B48301000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.html; + name = Dutch; + path = Dutch.lproj/XDarwinHelp.html; + refType = 4; + sourceTree = ""; + }; + F533214801A4B4D701000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Dutch; + path = Dutch.lproj/XDarwinHelp.html.cpp; + refType = 4; + sourceTree = ""; + }; + F54BF6EA017D500901000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + path = startXClients.cpp; + refType = 4; + sourceTree = ""; + }; + F54BF6EC017D506E01000001 = { + isa = PBXFileReference; + lastKnownFileType = text.script.sh; + path = startXClients; + refType = 4; + sourceTree = ""; + }; + F54BF6ED017D506E01000001 = { + fileRef = F54BF6EC017D506E01000001; + isa = PBXBuildFile; + settings = { + }; + }; + F5582948015DAD3B01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = quartzCommon.h; + refType = 4; + sourceTree = ""; + }; + F5614B3B0251124C01000114 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = fullscreen.c; + refType = 4; + sourceTree = ""; + }; + F5614B3D025112D901000114 = { + children = ( + F5614B3B0251124C01000114, + 3576829A0077B8F17F000001, + 0338412F0083BFE57F000001, + ); + isa = PBXGroup; + path = fullscreen; + refType = 4; + sourceTree = ""; + }; + F587E16001924C1D01000001 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = Swedish; + path = Swedish.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + F587E16101924C2F01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = Swedish; + path = Swedish.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + F587E16201924C5301000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Swedish; + path = Swedish.lproj/InfoPlist.strings.cpp; + refType = 4; + sourceTree = ""; + }; + F587E16301924C5E01000001 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = Swedish; + path = Swedish.lproj/Localizable.strings; + refType = 4; + sourceTree = ""; + }; + F587E16401924C6901000001 = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = Swedish; + path = Swedish.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + F587E16501924C7401000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.html; + name = Swedish; + path = Swedish.lproj/XDarwinHelp.html; + refType = 4; + sourceTree = ""; + }; + F587E16601924C9D01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Swedish; + path = Swedish.lproj/XDarwinHelp.html.cpp; + refType = 4; + sourceTree = ""; + }; + F58D65DB018F793801000001 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = French; + path = French.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + F58D65DC018F794D01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = French; + path = French.lproj/InfoPlist.strings.cpp; + refType = 4; + sourceTree = ""; + }; + F58D65DD018F798F01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = French; + path = French.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + F58D65DE018F79A001000001 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = French; + path = French.lproj/Localizable.strings; + refType = 4; + sourceTree = ""; + }; + F58D65DF018F79B101000001 = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = French; + path = French.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + F58D65E0018F79C001000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.html; + name = French; + path = French.lproj/XDarwinHelp.html; + refType = 4; + sourceTree = ""; + }; + F58D65E1018F79E001000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = French; + path = French.lproj/XDarwinHelp.html.cpp; + refType = 4; + sourceTree = ""; + }; + F5A94EF10314BAC70100011B = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = darwinEvents.c; + refType = 4; + sourceTree = ""; + }; + F5ACD25CC5B5E96601000001 = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = Spanish; + path = Spanish.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + F5ACD25DC5B5E97701000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Spanish; + path = Spanish.lproj/InfoPlist.strings.cpp; + refType = 4; + sourceTree = ""; + }; + F5ACD25EC5B5E98D01000001 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = Spanish; + path = Spanish.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + F5ACD25FC5B5E9AA01000001 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = Spanish; + path = Spanish.lproj/Localizable.strings; + refType = 4; + sourceTree = ""; + }; + F5ACD260C5B5E9DF01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = Spanish; + path = Spanish.lproj/XDarwinHelp.html.cpp; + refType = 4; + sourceTree = ""; + }; + F5ACD261C5B5EA2001000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.html; + name = Spanish; + path = Spanish.lproj/XDarwinHelp.html; + refType = 4; + sourceTree = ""; + }; + F5ACD262C5B5EA4D01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = Spanish; + path = Spanish.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + F5ACD263C5BE031F01000001 = { + isa = PBXFileReference; + lastKnownFileType = text.rtf; + name = ko; + path = ko.lproj/Credits.rtf; + refType = 4; + sourceTree = ""; + }; + F5ACD264C5BE035B01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = ko; + path = ko.lproj/InfoPlist.strings.cpp; + refType = 4; + sourceTree = ""; + }; + F5ACD265C5BE038601000001 = { + isa = PBXFileReference; + lastKnownFileType = wrapper.nib; + name = ko; + path = ko.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + F5ACD266C5BE03C501000001 = { + fileEncoding = 10; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = ko; + path = ko.lproj/Localizable.strings; + refType = 4; + sourceTree = ""; + }; + F5ACD267C5BE03FC01000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = ko; + path = ko.lproj/XDarwinHelp.html.cpp; + refType = 4; + sourceTree = ""; + }; + F5ACD268C5BE046401000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.html; + name = ko; + path = ko.lproj/XDarwinHelp.html; + refType = 4; + sourceTree = ""; + }; + F5ACD269C5BE049301000001 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.plist.strings; + name = ko; + path = ko.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + }; + 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 +#include +#include +#include +#include +#include + +// 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 +#undef BOOL + +#import + +@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 +#include +#include +#include +#include +#include +#include +#include + +// For power management notifications +#import +#import +#import +#import +#import + +// 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, ¬ify, 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 +#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 + +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 + +@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 +#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 + +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 + +#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 , University of Cambridge, April 2001 + * + * Special thanks to Richard Verhoeven 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 +#include + +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 , University of Cambridge, April 2001 + * + * Special thanks to Richard Verhoeven 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 +#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 +#include +#include +#include + +// 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 +#include + +#include "inputstr.h" +#include + +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 + +#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_ 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 +#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 + +#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 +#include + +#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 +#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 +#include +#include +#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 + +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 + +/* 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 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 + * Jens Owen + * Rickard E. (Rik) Faith + * + */ + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#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 + * Rickard E. (Rik) Faith + * + */ + +#ifdef XFree86LOADER +#include "xf86.h" +#include "xf86_ansic.h" +#else +#include +#include +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include +#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 + +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, "CFBundleShortVersionString") + || fgets (buf, sizeof (buf), fh) == NULL) + { + continue; + } + + ptr = strstr (buf, ""); + if (ptr == NULL) + continue; + + ptr += strlen (""); + + /* 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 + * + */ + +/* Prototypes for AppleDRI functions */ + +#ifndef _DRI_H_ +#define _DRI_H_ + +#include +#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 + * + */ + +#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 +#include + +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 +#include + +#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 +#include +#include + +/* 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 + + +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 +#include "windowstr.h" + +#include + +#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 +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 . + +The implementation of dumpkeymap is based upon information gathered on +September 3, 1997 by Eric Sunshine and Paul S. +McCarthy 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 +// 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 +// . +// +// The implementation of dumpkeymap is based upon information gathered +// on September 3, 1997 by Eric Sunshine and +// Paul S. McCarthy during an effort to reverse +// engineer the format of the NeXT .keymapping file. +// +// HISTORY +// +// v4 2000/12/01 Eric Sunshine +// 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 +// 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 +// 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 +// Created. +//----------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#if !defined(DUMPKEYMAP_FILE_ONLY) +#include +#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 +// 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 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 +. All rights reserved. +.PP +The implementation of +.I dumpkeymap +is based upon information gathered on September 3, 1997 by Eric Sunshine + and Paul S. McCarthy 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 + +#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 + +#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 , +David H. Dawes +.I , +and +Rickard E. (Rik) Faith +.IR . +.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 + * + * This file was originally taken from xc/lib/Xaw/Template.c + */ + +#include +#include +#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[] = +": canvas()\n\ +: canvas()\n\ +: canvas()\n\ +: 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 + * + * This file was originally taken from xc/lib/Xaw/Template.h + */ + +#ifndef _Canvas_h +#define _Canvas_h + +#include + +#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 + * + * 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 + +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 +#include + +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 + +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 + */ + +/** \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 +#endif + +#include "dmxconfig.h" +#include "dmxparse.h" +#include "dmxcompat.h" +#include "parser.h" +#include +#include +#include +#include + +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 + * + */ + +/** \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 + * + */ + +/** \file + * Provides interface for reading DMX configuration files and for + * combining that information with command-line configuration parameters. */ + + +#ifdef HAVE_DMX_CONFIG_H +#include +#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 : ""; + 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 + * + */ + +/** \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 + * + */ + +/** \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 +#endif + +#include +#include +#include +#include +#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 + * + */ + +/** \file + * Interface to DMX configuration file parser. \see dmxparse.c */ + +#ifndef _DMXPARSE_H_ +#define _DMXPARSE_H_ + +#include /* 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 + * + */ + +/** \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 +#endif + +#include "dmxconfig.h" +#include "dmxparse.h" +#include "dmxprint.h" +#include "parser.h" +#include +#include +#include + +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 + * + */ + +/** \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 + * + * 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 +.\" +.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 + * + */ + +%{ +#ifdef HAVE_DMX_CONFIG_H +#include +#endif + +#include "dmxparse.h" +#include +#include +#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 '{' '}' ';' '/' T_VIRTUAL T_DISPLAY T_WALL T_OPTION T_PARAM +%token T_STRING +%token T_DIMENSION T_OFFSET T_ORIGIN +%token T_COMMENT T_LINE_COMMENT + + /* Non-termials */ +%type Display Wall Terminal Open Close +%type NameList Name +%type Dimension Offset Origin +%type PartialDim +%type FullDim +%type DisplayEntry +%type