summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--GL/glx/glxext.c9
-rw-r--r--GL/glx/glxscreens.c19
-rw-r--r--XTrap/xtrapddmi.c6
-rw-r--r--XTrap/xtrapdi.c6
-rw-r--r--Xext/Makefile.am14
-rw-r--r--Xext/SecurityPolicy88
-rw-r--r--Xext/appgroup.c10
-rw-r--r--Xext/bigreq.c8
-rw-r--r--Xext/cup.c9
-rw-r--r--Xext/dpms.c10
-rw-r--r--Xext/dpmsproc.h4
-rw-r--r--Xext/dpmsstubs.c4
-rw-r--r--Xext/mbuf.c2
-rw-r--r--Xext/mitmisc.c6
-rw-r--r--Xext/panoramiX.c41
-rw-r--r--Xext/panoramiXprocs.c8
-rw-r--r--Xext/saver.c66
-rw-r--r--Xext/security.c1470
-rw-r--r--Xext/securitysrv.h6
-rw-r--r--Xext/shape.c26
-rw-r--r--Xext/shm.c32
-rw-r--r--Xext/sync.c16
-rw-r--r--Xext/xace.c124
-rw-r--r--Xext/xace.h29
-rw-r--r--Xext/xacestr.h87
-rw-r--r--Xext/xcmisc.c8
-rw-r--r--Xext/xevie.c19
-rw-r--r--Xext/xf86bigfont.c4
-rw-r--r--Xext/xprint.c174
-rw-r--r--Xext/xres.c21
-rw-r--r--Xext/xselinux.c1434
-rw-r--r--Xext/xselinux.h195
-rw-r--r--Xext/xtest.c33
-rw-r--r--Xext/xvdisp.c29
-rw-r--r--Xext/xvdix.h9
-rw-r--r--Xext/xvmain.c32
-rw-r--r--Xext/xvmc.c23
-rw-r--r--Xi/allowev.c8
-rw-r--r--Xi/chgdctl.c7
-rw-r--r--Xi/chgfctl.c8
-rw-r--r--Xi/chgkmap.c7
-rw-r--r--Xi/chgprop.c3
-rw-r--r--Xi/chgptr.c2
-rw-r--r--Xi/closedev.c9
-rw-r--r--Xi/devbell.c9
-rw-r--r--Xi/exevents.c41
-rw-r--r--Xi/extinit.c25
-rw-r--r--Xi/getbmap.c8
-rw-r--r--Xi/getdctl.c9
-rw-r--r--Xi/getfctl.c9
-rw-r--r--Xi/getfocus.c8
-rw-r--r--Xi/getkmap.c8
-rw-r--r--Xi/getmmap.c8
-rw-r--r--Xi/getprop.c3
-rw-r--r--Xi/getselev.c3
-rw-r--r--Xi/getvers.c1
-rw-r--r--Xi/grabdev.c15
-rw-r--r--Xi/grabdevb.c23
-rw-r--r--Xi/grabdevk.c23
-rw-r--r--Xi/gtmotion.c9
-rw-r--r--Xi/listdev.c10
-rw-r--r--Xi/opendev.c7
-rw-r--r--Xi/queryst.c9
-rw-r--r--Xi/selectev.c3
-rw-r--r--Xi/sendexev.c8
-rw-r--r--Xi/setbmap.c7
-rw-r--r--Xi/setdval.c8
-rw-r--r--Xi/setfocus.c7
-rw-r--r--Xi/setmmap.c7
-rw-r--r--Xi/setmode.c8
-rw-r--r--Xi/stubs.c2
-rw-r--r--Xi/ungrdev.c8
-rw-r--r--Xi/ungrdevb.c16
-rw-r--r--Xi/ungrdevk.c16
-rw-r--r--afb/afb.h19
-rw-r--r--afb/afbfillarc.c3
-rw-r--r--afb/afbfillrct.c3
-rw-r--r--afb/afbfillsp.c15
-rw-r--r--afb/afbgc.c7
-rw-r--r--afb/afbimggblt.c4
-rw-r--r--afb/afbline.c6
-rw-r--r--afb/afbpixmap.c1
-rw-r--r--afb/afbply1rct.c4
-rw-r--r--afb/afbplygblt.c4
-rw-r--r--afb/afbpolypnt.c4
-rw-r--r--afb/afbscrinit.c42
-rw-r--r--afb/afbtegblt.c4
-rw-r--r--afb/afbwindow.c1
-rw-r--r--afb/afbzerarc.c4
-rw-r--r--cfb/cfb.h9
-rw-r--r--cfb/cfballpriv.c30
-rw-r--r--cfb/cfbmap.h6
-rw-r--r--cfb/cfbpixmap.c1
-rw-r--r--cfb/cfbrrop.h3
-rw-r--r--cfb/cfbscrinit.c18
-rw-r--r--cfb/cfbunmap.h6
-rw-r--r--cfb/cfbwindow.c4
-rw-r--r--composite/compalloc.c10
-rw-r--r--composite/compext.c57
-rw-r--r--composite/compinit.c30
-rw-r--r--composite/compint.h16
-rw-r--r--config/dbus.c2
-rw-r--r--configure.ac40
-rwxr-xr-xdamageext/damageext.c10
-rw-r--r--damageext/damageextint.h2
-rw-r--r--dbe/dbe.c224
-rw-r--r--dbe/dbestruct.h37
-rw-r--r--dbe/midbe.c49
-rw-r--r--dbe/midbestr.h12
-rw-r--r--dix/Makefile.am6
-rw-r--r--dix/colormap.c39
-rw-r--r--dix/cursor.c107
-rw-r--r--dix/deprecated.c162
-rw-r--r--dix/devices.c193
-rw-r--r--dix/dispatch.c738
-rw-r--r--dix/dixfonts.c26
-rw-r--r--dix/dixutils.c104
-rw-r--r--dix/events.c194
-rw-r--r--dix/extension.c70
-rw-r--r--dix/gc.c100
-rw-r--r--dix/getevents.c12
-rw-r--r--dix/grabs.c11
-rw-r--r--dix/main.c66
-rw-r--r--dix/pixmap.c27
-rw-r--r--dix/privates.c517
-rw-r--r--dix/property.c155
-rw-r--r--dix/protocol.txt1054
-rw-r--r--dix/registry.c328
-rw-r--r--dix/resource.c165
-rw-r--r--dix/window.c247
-rw-r--r--doc/Makefile.am2
-rw-r--r--doc/SecurityPolicy.man.pre258
-rw-r--r--doc/Xserver.man.pre13
-rw-r--r--exa/exa.c20
-rw-r--r--exa/exa_priv.h10
-rw-r--r--fb/fb.h20
-rw-r--r--fb/fballpriv.c48
-rw-r--r--fb/fboverlay.c19
-rw-r--r--fb/fboverlay.h9
-rw-r--r--fb/fbpixmap.c1
-rw-r--r--fb/fbpseudocolor.c50
-rw-r--r--fb/fbscreen.c6
-rw-r--r--fb/fbwindow.c4
-rw-r--r--fb/wfbrename.h22
-rw-r--r--hw/dmx/dmxcmap.c14
-rw-r--r--hw/dmx/dmxcmap.h9
-rw-r--r--hw/dmx/dmxcursor.c8
-rw-r--r--hw/dmx/dmxcursor.h7
-rw-r--r--hw/dmx/dmxdpms.c9
-rw-r--r--hw/dmx/dmxfont.c7
-rw-r--r--hw/dmx/dmxgc.c6
-rw-r--r--hw/dmx/dmxgc.h4
-rw-r--r--hw/dmx/dmxpict.c3
-rw-r--r--hw/dmx/dmxpict.h10
-rw-r--r--hw/dmx/dmxpixmap.c5
-rw-r--r--hw/dmx/dmxpixmap.h4
-rw-r--r--hw/dmx/dmxscrinit.c46
-rw-r--r--hw/dmx/dmxscrinit.h2
-rw-r--r--hw/dmx/dmxwindow.c3
-rw-r--r--hw/dmx/dmxwindow.h6
-rw-r--r--hw/dmx/input/dmxconsole.c13
-rw-r--r--hw/dmx/input/dmxeq.c4
-rw-r--r--hw/kdrive/ephyr/ephyr.c2
-rw-r--r--hw/kdrive/savage/s3draw.c17
-rw-r--r--hw/kdrive/savage/s3draw.h18
-rw-r--r--hw/kdrive/src/kaa.c22
-rw-r--r--hw/kdrive/src/kaa.h13
-rw-r--r--hw/kdrive/src/kdrive.h8
-rw-r--r--hw/kdrive/src/kxv.c44
-rw-r--r--hw/kdrive/vxworks/vxkbd.c2
-rw-r--r--hw/xfree86/common/xf86.h10
-rw-r--r--hw/xfree86/common/xf86DGA.c44
-rw-r--r--hw/xfree86/common/xf86DPMS.c48
-rw-r--r--hw/xfree86/common/xf86Events.c6
-rw-r--r--hw/xfree86/common/xf86Globals.c8
-rw-r--r--hw/xfree86/common/xf86Init.c26
-rw-r--r--hw/xfree86/common/xf86PM.c2
-rw-r--r--hw/xfree86/common/xf86RandR.c20
-rw-r--r--hw/xfree86/common/xf86VidMode.c27
-rw-r--r--hw/xfree86/common/xf86Xinput.c1
-rw-r--r--hw/xfree86/common/xf86cmap.c122
-rw-r--r--hw/xfree86/common/xf86fbman.c148
-rw-r--r--hw/xfree86/common/xf86sbusBus.c13
-rw-r--r--hw/xfree86/common/xf86xv.c45
-rw-r--r--hw/xfree86/common/xf86xvmc.c20
-rw-r--r--hw/xfree86/common/xf86xvpriv.h3
-rw-r--r--hw/xfree86/dixmods/extmod/modinit.h5
-rw-r--r--hw/xfree86/dixmods/extmod/xf86dga2.c30
-rw-r--r--hw/xfree86/dixmods/extmod/xf86misc.c40
-rw-r--r--hw/xfree86/dixmods/extmod/xf86vmode.c43
-rw-r--r--hw/xfree86/dixmods/extmod/xvmod.c2
-rw-r--r--hw/xfree86/dixmods/extmod/xvmodproc.h2
-rw-r--r--hw/xfree86/dri/dri.c52
-rw-r--r--hw/xfree86/dri/dristruct.h22
-rw-r--r--hw/xfree86/exa/examodule.c18
-rw-r--r--hw/xfree86/loader/dixsym.c64
-rw-r--r--hw/xfree86/loader/misym.c4
-rw-r--r--hw/xfree86/loader/xf86sym.c4
-rw-r--r--hw/xfree86/modes/xf86Cursors.c5
-rw-r--r--hw/xfree86/modes/xf86RandR12.c28
-rw-r--r--hw/xfree86/os-support/solaris/sun_mouse.c14
-rw-r--r--hw/xfree86/rac/xf86RAC.c68
-rw-r--r--hw/xfree86/ramdac/xf86Cursor.c75
-rw-r--r--hw/xfree86/ramdac/xf86CursorPriv.h2
-rw-r--r--hw/xfree86/ramdac/xf86HWCurs.c20
-rw-r--r--hw/xfree86/shadowfb/shadow.c20
-rw-r--r--hw/xfree86/xaa/xaaDashLine.c3
-rw-r--r--hw/xfree86/xaa/xaaGC.c3
-rw-r--r--hw/xfree86/xaa/xaaGCmisc.c3
-rw-r--r--hw/xfree86/xaa/xaaInit.c45
-rw-r--r--hw/xfree86/xaa/xaaLineMisc.c3
-rw-r--r--hw/xfree86/xaa/xaaOverlayDF.c15
-rw-r--r--hw/xfree86/xaa/xaaStateChange.c15
-rw-r--r--hw/xfree86/xaa/xaaWrapper.c31
-rw-r--r--hw/xfree86/xaa/xaalocal.h22
-rw-r--r--hw/xfree86/xaa/xaawrap.h14
-rw-r--r--hw/xfree86/xf4bpp/mfbfillarc.c3
-rw-r--r--hw/xfree86/xf4bpp/mfbimggblt.c3
-rw-r--r--hw/xfree86/xf4bpp/mfbzerarc.c3
-rw-r--r--hw/xfree86/xf4bpp/ppcArea.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcGC.c10
-rw-r--r--hw/xfree86/xf4bpp/ppcPixFS.c24
-rw-r--r--hw/xfree86/xf4bpp/ppcPixmap.c1
-rw-r--r--hw/xfree86/xf4bpp/ppcPolyPnt.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcWinFS.c24
-rw-r--r--hw/xfree86/xf4bpp/vgaGC.c2
-rw-r--r--hw/xfree86/xf8_32bpp/cfb8_32.h14
-rw-r--r--hw/xfree86/xf8_32bpp/cfbscrinit.c33
-rw-r--r--hw/xfree86/xf8_32bpp/xf86overlay.c35
-rw-r--r--hw/xgl/egl/kinput.c2
-rw-r--r--hw/xgl/egl/xegl.c20
-rw-r--r--hw/xgl/egl/xegl.h6
-rw-r--r--hw/xgl/glx/xglx.c26
-rw-r--r--hw/xgl/xgl.h33
-rw-r--r--hw/xgl/xglinput.c2
-rw-r--r--hw/xgl/xglpixmap.c1
-rw-r--r--hw/xgl/xglscreen.c3
-rw-r--r--hw/xgl/xglxv.c8
-rw-r--r--hw/xnest/Cursor.c6
-rw-r--r--hw/xnest/GC.c2
-rw-r--r--hw/xnest/Init.c2
-rw-r--r--hw/xnest/Pixmap.c8
-rw-r--r--hw/xnest/Screen.c20
-rw-r--r--hw/xnest/Window.c2
-rw-r--r--hw/xnest/XNCursor.h9
-rw-r--r--hw/xnest/XNGC.h6
-rw-r--r--hw/xnest/XNPixmap.h6
-rw-r--r--hw/xnest/XNWindow.h6
-rw-r--r--hw/xprint/attributes.c27
-rw-r--r--hw/xprint/pcl/Pcl.h8
-rw-r--r--hw/xprint/pcl/PclArc.c2
-rw-r--r--hw/xprint/pcl/PclColor.c28
-rw-r--r--hw/xprint/pcl/PclGC.c15
-rw-r--r--hw/xprint/pcl/PclInit.c62
-rw-r--r--hw/xprint/pcl/PclLine.c4
-rw-r--r--hw/xprint/pcl/PclPixel.c8
-rw-r--r--hw/xprint/pcl/PclPolygon.c6
-rw-r--r--hw/xprint/pcl/PclPrint.c20
-rw-r--r--hw/xprint/pcl/PclText.c4
-rw-r--r--hw/xprint/pcl/PclWindow.c7
-rw-r--r--hw/xprint/pcl/Pclmap.h10
-rw-r--r--hw/xprint/ps/Ps.h8
-rw-r--r--hw/xprint/ps/PsGC.c14
-rw-r--r--hw/xprint/ps/PsInit.c48
-rw-r--r--hw/xprint/ps/PsPixmap.c3
-rw-r--r--hw/xprint/ps/PsPrint.c33
-rw-r--r--hw/xprint/ps/PsWindow.c7
-rw-r--r--hw/xprint/raster/Raster.c44
-rw-r--r--hw/xquartz/darwin.c2
-rw-r--r--hw/xquartz/darwin.h6
-rw-r--r--hw/xquartz/darwinEvents.c2
-rw-r--r--hw/xquartz/quartz.c12
-rw-r--r--hw/xquartz/quartzCommon.h5
-rw-r--r--hw/xquartz/quartzCursor.c26
-rw-r--r--hw/xquartz/xpr/dri.c47
-rw-r--r--hw/xquartz/xpr/dristruct.h21
-rw-r--r--hw/xquartz/xpr/xprCursor.c20
-rw-r--r--hw/xquartz/xpr/xprFrame.c2
-rw-r--r--hw/xwin/win.h40
-rw-r--r--hw/xwin/winallpriv.c18
-rwxr-xr-xhw/xwin/winclipboardwrappers.c1
-rw-r--r--hw/xwin/wincursor.c3
-rw-r--r--hw/xwin/winfillsp.c9
-rw-r--r--hw/xwin/winglobals.c10
-rw-r--r--hw/xwin/winmultiwindowwndproc.c2
-rw-r--r--hw/xwin/winpixmap.c7
-rw-r--r--hw/xwin/winscrinit.c3
-rw-r--r--hw/xwin/winsetsp.c9
-rwxr-xr-xhw/xwin/winwin32rootless.c2
-rw-r--r--include/Makefile.am3
-rw-r--r--include/colormapst.h3
-rw-r--r--include/cursor.h26
-rw-r--r--include/cursorstr.h6
-rw-r--r--include/dix-config.h.in15
-rw-r--r--include/dix.h75
-rw-r--r--include/dixaccess.h53
-rw-r--r--include/dixfont.h6
-rw-r--r--include/dixgrabs.h1
-rw-r--r--include/dixstruct.h7
-rw-r--r--include/extension.h8
-rw-r--r--include/extinit.h5
-rw-r--r--include/extnsionst.h7
-rw-r--r--include/gc.h4
-rw-r--r--include/gcstruct.h3
-rw-r--r--include/input.h18
-rw-r--r--include/inputstr.h5
-rw-r--r--include/miscstruct.h13
-rw-r--r--include/os.h2
-rw-r--r--include/pixmapstr.h14
-rw-r--r--include/privates.h157
-rw-r--r--include/property.h12
-rw-r--r--include/propertyst.h2
-rw-r--r--include/registry.h64
-rw-r--r--include/resource.h92
-rw-r--r--include/screenint.h38
-rw-r--r--include/scrnintstr.h11
-rw-r--r--include/selection.h4
-rw-r--r--include/window.h16
-rw-r--r--include/windowstr.h3
-rw-r--r--include/xkbsrv.h50
-rw-r--r--include/xorg-config.h.in3
-rw-r--r--include/xorg-server.h.in3
-rw-r--r--mfb/mfb.h10
-rw-r--r--mfb/mfbbitblt.c18
-rw-r--r--mfb/mfbfillarc.c3
-rw-r--r--mfb/mfbfillrct.c3
-rw-r--r--mfb/mfbfillsp.c9
-rw-r--r--mfb/mfbgc.c10
-rw-r--r--mfb/mfbimggblt.c3
-rw-r--r--mfb/mfbline.c6
-rw-r--r--mfb/mfbpixmap.c1
-rw-r--r--mfb/mfbpolypnt.c3
-rw-r--r--mfb/mfbscrinit.c25
-rw-r--r--mfb/mfbwindow.c1
-rw-r--r--mfb/mfbzerarc.c3
-rw-r--r--mi/mi.h3
-rw-r--r--mi/mibank.c18
-rw-r--r--mi/midispcur.c56
-rw-r--r--mi/mieq.c4
-rw-r--r--mi/miinitext.c18
-rw-r--r--mi/miline.h8
-rw-r--r--mi/mioverlay.c27
-rw-r--r--mi/mipointer.c15
-rw-r--r--mi/mipointer.h3
-rw-r--r--mi/miscrinit.c25
-rw-r--r--mi/misprite.c78
-rw-r--r--miext/cw/cw.c53
-rw-r--r--miext/cw/cw.h29
-rwxr-xr-xmiext/damage/damage.c41
-rwxr-xr-xmiext/damage/damagestr.h15
-rw-r--r--miext/rootless/accel/rlAccel.c13
-rw-r--r--miext/rootless/rootlessCommon.c8
-rw-r--r--miext/rootless/rootlessCommon.h21
-rw-r--r--miext/rootless/rootlessGC.c10
-rw-r--r--miext/rootless/rootlessScreen.c36
-rw-r--r--miext/rootless/rootlessWindow.c14
-rw-r--r--miext/shadow/shadow.c15
-rw-r--r--miext/shadow/shadow.h5
-rw-r--r--os/Makefile.am7
-rw-r--r--os/WaitFor.c4
-rw-r--r--os/access.c32
-rw-r--r--os/auth.c11
-rw-r--r--os/connection.c20
-rw-r--r--os/osdep.h3
-rw-r--r--os/secauth.c202
-rw-r--r--os/utils.c12
-rw-r--r--randr/randr.c16
-rw-r--r--randr/randrstr.h10
-rw-r--r--randr/rrcrtc.c5
-rw-r--r--randr/rrmode.c3
-rw-r--r--randr/rroutput.c5
-rw-r--r--record/record.c15
-rw-r--r--render/animcur.c32
-rw-r--r--render/glyph.c323
-rw-r--r--render/glyphstr.h43
-rw-r--r--render/mirect.c2
-rw-r--r--render/picture.c149
-rw-r--r--render/picture.h4
-rw-r--r--render/picturestr.h44
-rw-r--r--render/render.c130
-rwxr-xr-xxfixes/cursor.c81
-rwxr-xr-xxfixes/region.c34
-rwxr-xr-xxfixes/saveset.c2
-rwxr-xr-xxfixes/select.c9
-rwxr-xr-xxfixes/xfixes.c6
-rwxr-xr-xxfixes/xfixesint.h2
-rw-r--r--xkb/ddxDevBtn.c2
-rw-r--r--xkb/ddxFakeBtn.c2
-rw-r--r--xkb/ddxFakeMtn.c2
-rw-r--r--xkb/xkb.c101
-rw-r--r--xkb/xkbAccessX.c2
-rw-r--r--xkb/xkbActions.c23
-rw-r--r--xkb/xkbEvents.c2
-rw-r--r--xkb/xkbLEDs.c10
-rw-r--r--xkb/xkbPrOtherEv.c2
-rw-r--r--xkb/xkbUtils.c147
397 files changed, 7796 insertions, 7407 deletions
diff --git a/.gitignore b/.gitignore
index 37f35f46f..3e5001a7e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -97,8 +97,6 @@ cfb32/cfbzerarcG.c
cfb32/cfbzerarcX.c
doc/Xserver.1x
doc/Xserver.man
-doc/SecurityPolicy.5
-doc/SecurityPolicy.man
hw/dmx/Xdmx
hw/dmx/Xdmx.1x
hw/dmx/config/dmxtodmx
diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c
index f9b872c41..85d8debd4 100644
--- a/GL/glx/glxext.c
+++ b/GL/glx/glxext.c
@@ -27,6 +27,7 @@
#include "glxserver.h"
#include <windowstr.h>
#include <propertyst.h>
+#include "privates.h"
#include <os.h>
#include "g_disptab.h"
#include "unpack.h"
@@ -53,7 +54,7 @@ RESTYPE __glXSwapBarrierRes;
*/
xGLXSingleReply __glXReply;
-static int glxClientPrivateIndex;
+static DevPrivateKey glxClientPrivateKey = &glxClientPrivateKey;
/*
** Client that called into GLX dispatch.
@@ -204,7 +205,7 @@ int __glXError(int error)
__GLXclientState *
glxGetClient(ClientPtr pClient)
{
- return (__GLXclientState *) pClient->devPrivates[glxClientPrivateIndex].ptr;
+ return dixLookupPrivate(&pClient->devPrivates, glxClientPrivateKey);
}
static void
@@ -274,9 +275,7 @@ void GlxExtensionInit(void)
__glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone);
__glXSwapBarrierRes = CreateNewResourceType((DeleteType)SwapBarrierGone);
- glxClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (glxClientPrivateIndex,
- sizeof (__GLXclientState)))
+ if (!dixRequestPrivate(glxClientPrivateKey, sizeof (__GLXclientState)))
return;
if (!AddCallback (&ClientStateCallback, glxClientCallback, 0))
return;
diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c
index d57b3a912..88773a785 100644
--- a/GL/glx/glxscreens.c
+++ b/GL/glx/glxscreens.c
@@ -42,12 +42,13 @@
#include <os.h>
#include <colormapst.h>
+#include "privates.h"
#include "glxserver.h"
#include "glxutil.h"
#include "glxext.h"
#include "glcontextmodes.h"
-static int glxScreenPrivateIndex;
+static DevPrivateKey glxScreenPrivateKey = &glxScreenPrivateKey;
const char GLServerVersion[] = "1.4";
static const char GLServerExtensions[] =
@@ -269,7 +270,7 @@ glxCloseScreen (int index, ScreenPtr pScreen)
__GLXscreen *
glxGetScreen(ScreenPtr pScreen)
{
- return (__GLXscreen *) pScreen->devPrivates[glxScreenPrivateIndex].ptr;
+ return dixLookupPrivate(&pScreen->devPrivates, glxScreenPrivateKey);
}
void GlxSetVisualConfigs(int nconfigs,
@@ -497,19 +498,9 @@ void GlxSetVisualConfig(int config)
void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
{
- static int glxGeneration;
__GLcontextModes *m;
int i;
- if (glxGeneration != serverGeneration)
- {
- glxScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (glxScreenPrivateIndex == -1)
- return;
-
- glxGeneration = serverGeneration;
- }
-
pGlxScreen->pScreen = pScreen;
pGlxScreen->GLextensions = xstrdup(GLServerExtensions);
pGlxScreen->GLXvendor = xstrdup(GLXServerVendorName);
@@ -548,9 +539,9 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
break;
}
- pScreen->devPrivates[glxScreenPrivateIndex].ptr = (pointer) pGlxScreen;
+ dixSetPrivate(&pScreen->devPrivates, glxScreenPrivateKey, pGlxScreen);
}
-
+
void __glXScreenDestroy(__GLXscreen *screen)
{
xfree(screen->GLXvendor);
diff --git a/XTrap/xtrapddmi.c b/XTrap/xtrapddmi.c
index 73a20c1f6..3f1a72ab8 100644
--- a/XTrap/xtrapddmi.c
+++ b/XTrap/xtrapddmi.c
@@ -52,7 +52,7 @@ SOFTWARE.
#define NEED_REPLIES
#define NEED_EVENTS
#include <X11/X.h> /* From library include environment */
-#include "input.h" /* From server include env. (must be before Xlib.h!) */
+#include "inputstr.h" /* From server include env. (must be before Xlib.h!) */
#ifdef PC
# include "scrintst.h" /* Screen struct */
# include "extnsist.h"
@@ -96,8 +96,8 @@ int XETrapSimulateXEvent(register xXTrapInputReq *request,
xEvent xev;
register int x = request->input.x;
register int y = request->input.y;
- DevicePtr keydev = LookupKeyboardDevice();
- DevicePtr ptrdev = LookupPointerDevice();
+ DevicePtr keydev = (DevicePtr)inputInfo.keyboard;
+ DevicePtr ptrdev = (DevicePtr)inputInfo.pointer;
if (request->input.screen < screenInfo.numScreens)
{
diff --git a/XTrap/xtrapdi.c b/XTrap/xtrapdi.c
index 80124fa73..7dd9584a0 100644
--- a/XTrap/xtrapdi.c
+++ b/XTrap/xtrapdi.c
@@ -58,7 +58,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <X11/Xos.h>
#include <X11/X.h>
#include <X11/Xproto.h>
-#include "input.h" /* Server DevicePtr definitions */
+#include "inputstr.h" /* Server DevicePtr definitions */
#include "misc.h" /* Server swapping macros */
#include "dixstruct.h" /* Server ClientRec definitions */
#include "resource.h" /* Used with the MakeAtom call */
@@ -277,7 +277,7 @@ Bool XETrapRedirectDevices()
/* Do we need to redirect the keyboard device? */
if (XETrapKbdDev == NULL)
{
- if ((XETrapKbdDev = LookupKeyboardDevice()) == NULL)
+ if ((XETrapKbdDev = (DevicePtr)inputInfo.keyboard) == NULL)
{
retval = False;
}
@@ -302,7 +302,7 @@ Bool XETrapRedirectDevices()
#ifndef VECTORED_EVENTS
if (XETrapPtrDev == NULL)
{
- if ((XETrapPtrDev = LookupPointerDevice()) == 0L)
+ if ((XETrapPtrDev = (DevicePtr)inputInfo.pointer) == 0L)
{
retval = False;
}
diff --git a/Xext/Makefile.am b/Xext/Makefile.am
index 946c118b1..f57e59910 100644
--- a/Xext/Makefile.am
+++ b/Xext/Makefile.am
@@ -33,9 +33,6 @@ MODULE_SRCS = \
sync.c \
xcmisc.c
-# Extra configuration files ship with some extensions
-SERVERCONFIG_DATA =
-
# Optional sources included if extension enabled by configure.ac rules
# MIT Shared Memory extension
@@ -75,13 +72,17 @@ if XACE
BUILTIN_SRCS += $(XACE_SRCS)
endif
+# SELinux extension: provides SELinux policy support for X objects
+# requires X-ACE extension
+XSELINUX_SRCS = xselinux.c xselinux.h
+if XSELINUX
+BUILTIN_SRCS += $(XSELINUX_SRCS)
+endif
+
# Security extension: multi-level security to protect clients from each other
XCSECURITY_SRCS = security.c securitysrv.h
if XCSECURITY
BUILTIN_SRCS += $(XCSECURITY_SRCS)
-
-SERVERCONFIG_DATA += SecurityPolicy
-AM_CFLAGS += -DDEFAULTPOLICYFILE=\"$(SERVERCONFIGdir)/SecurityPolicy\"
endif
XCALIBRATE_SRCS = xcalibrate.c
@@ -159,7 +160,6 @@ libXextmodule_la_SOURCES = $(MODULE_SRCS)
endif
EXTRA_DIST = \
- $(SERVERCONFIG_DATA) \
$(MITSHM_SRCS) \
$(XV_SRCS) \
$(RES_SRCS) \
diff --git a/Xext/SecurityPolicy b/Xext/SecurityPolicy
deleted file mode 100644
index cc521c263..000000000
--- a/Xext/SecurityPolicy
+++ /dev/null
@@ -1,88 +0,0 @@
-version-1
-
-# $Xorg: SecurityPolicy,v 1.3 2000/08/17 19:47:56 cpqbld Exp $
-
-# The site policy fields are interpreted by the XC-QUERY-SECURITY-1
-# authorization protocol. The values are arbitrary and site-specific.
-# Refer to the Security Extension Specification for the usage of the policies.
-#sitepolicy A
-#sitepolicy B
-#sitepolicy C
-
-# Property access rules:
-# property <property> <window> <permissions>
-# <window> ::= any | root | <propertyselector>
-# <propertyselector> ::= <property> | <property>=<value>
-# <permissions> :== [ <operation> | <action> | <space> ]*
-# <operation> :== r | w | d
-# r read
-# w write
-# d delete
-# <action> :== a | i | e
-# a allow
-# i ignore
-# e error
-
-# Allow reading of application resources, but not writing.
-property RESOURCE_MANAGER root ar iw
-property SCREEN_RESOURCES root ar iw
-
-# Ignore attempts to use cut buffers. Giving errors causes apps to crash,
-# and allowing access may give away too much information.
-property CUT_BUFFER0 root irw
-property CUT_BUFFER1 root irw
-property CUT_BUFFER2 root irw
-property CUT_BUFFER3 root irw
-property CUT_BUFFER4 root irw
-property CUT_BUFFER5 root irw
-property CUT_BUFFER6 root irw
-property CUT_BUFFER7 root irw
-
-# If you are using Motif, you probably want these.
-property _MOTIF_DEFAULT_BINDINGS root ar iw
-property _MOTIF_DRAG_WINDOW root ar iw
-property _MOTIF_DRAG_TARGETS any ar iw
-property _MOTIF_DRAG_ATOMS any ar iw
-property _MOTIF_DRAG_ATOM_PAIRS any ar iw
-
-# If you are running CDE you also need these
-property _MOTIF_WM_INFO root arw
-property TT_SESSION root irw
-property WM_ICON_SIZE root irw
-property "SDT Pixel Set" any irw
-
-# The next two rules let xwininfo -tree work when untrusted.
-property WM_NAME any ar
-
-# Allow read of WM_CLASS, but only for windows with WM_NAME.
-# This might be more restrictive than necessary, but demonstrates
-# the <required property> facility, and is also an attempt to
-# say "top level windows only."
-property WM_CLASS WM_NAME ar
-
-# These next three let xlsclients work untrusted. Think carefully
-# before including these; giving away the client machine name and command
-# may be exposing too much.
-property WM_STATE WM_NAME ar
-property WM_CLIENT_MACHINE WM_NAME ar
-property WM_COMMAND WM_NAME ar
-
-# To let untrusted clients use the standard colormaps created by
-# xstdcmap, include these lines.
-property RGB_DEFAULT_MAP root ar
-property RGB_BEST_MAP root ar
-property RGB_RED_MAP root ar
-property RGB_GREEN_MAP root ar
-property RGB_BLUE_MAP root ar
-property RGB_GRAY_MAP root ar
-
-# To let untrusted clients use the color management database created
-# by xcmsdb, include these lines.
-property XDCCC_LINEAR_RGB_CORRECTION root ar
-property XDCCC_LINEAR_RGB_MATRICES root ar
-property XDCCC_GRAY_SCREENWHITEPOINT root ar
-property XDCCC_GRAY_CORRECTION root ar
-
-# To let untrusted clients use the overlay visuals that many vendors
-# support, include this line.
-property SERVER_OVERLAY_VISUALS root ar
diff --git a/Xext/appgroup.c b/Xext/appgroup.c
index 7bd205587..c40782df5 100644
--- a/Xext/appgroup.c
+++ b/Xext/appgroup.c
@@ -345,7 +345,7 @@ int AttrValidate(
ColormapPtr pColormap;
rc = dixLookupWindow(&pWin, pAppGrp->default_root, client,
- DixUnknownAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
pScreen = pWin->drawable.pScreen;
@@ -367,8 +367,10 @@ int AttrValidate(
}
if (pAppGrp->default_colormap) {
- pColormap = (ColormapPtr)LookupIDByType (pAppGrp->default_colormap, RT_COLORMAP);
- /* XXX check that pColormap is not NULL */
+ rc = dixLookupResource((pointer *)&pColormap, pAppGrp->default_colormap,
+ RT_COLORMAP, client, DixUseAccess);
+ if (rc != Success)
+ return rc;
if (pColormap->pScreen != pScreen)
return BadColor;
if (pColormap->pVisual->vid != (pAppGrp->root_visual ? pAppGrp->root_visual : pScreen->rootVisual))
@@ -470,7 +472,7 @@ int ProcXagQuery(
int n, rc;
REQUEST_SIZE_MATCH (xXagQueryReq);
- rc = dixLookupClient(&pClient, stuff->resource, client, DixUnknownAccess);
+ rc = dixLookupClient(&pClient, stuff->resource, client, DixGetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xext/bigreq.c b/Xext/bigreq.c
index e7d410250..4f0724bc1 100644
--- a/Xext/bigreq.c
+++ b/Xext/bigreq.c
@@ -50,11 +50,9 @@ static DISPATCH_PROC(ProcBigReqDispatch);
void
BigReqExtensionInit(INITARGS)
{
- (void) AddExtension(XBigReqExtensionName, 0, 0,
- ProcBigReqDispatch, ProcBigReqDispatch,
- BigReqResetProc, StandardMinorOpcode);
-
- DeclareExtensionSecurity(XBigReqExtensionName, TRUE);
+ AddExtension(XBigReqExtensionName, 0, 0,
+ ProcBigReqDispatch, ProcBigReqDispatch,
+ BigReqResetProc, StandardMinorOpcode);
}
/*ARGSUSED*/
diff --git a/Xext/cup.c b/Xext/cup.c
index 0a83855e5..d0e820c41 100644
--- a/Xext/cup.c
+++ b/Xext/cup.c
@@ -204,12 +204,13 @@ int ProcStoreColors(
{
REQUEST (xXcupStoreColorsReq);
ColormapPtr pcmp;
+ int rc;
REQUEST_AT_LEAST_SIZE (xXcupStoreColorsReq);
- pcmp = (ColormapPtr) SecurityLookupIDByType (client, stuff->cmap,
- RT_COLORMAP, DixWriteAccess);
+ rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP,
+ client, DixAddAccess);
- if (pcmp) {
+ if (rc == Success) {
int ncolors, n;
xXcupStoreColorsReply rep;
xColorItem* cptr;
@@ -253,7 +254,7 @@ int ProcStoreColors(
return client->noClientException;
} else {
client->errorValue = stuff->cmap;
- return BadColor;
+ return (rc == BadValue) ? BadColor : rc;
}
}
diff --git a/Xext/dpms.c b/Xext/dpms.c
index b062b53aa..6f01fa348 100644
--- a/Xext/dpms.c
+++ b/Xext/dpms.c
@@ -73,9 +73,9 @@ static void DPMSResetProc(ExtensionEntry* extEntry);
void
DPMSExtensionInit(INITARGS)
{
- (void) AddExtension(DPMSExtensionName, 0, 0,
- ProcDPMSDispatch, SProcDPMSDispatch,
- DPMSResetProc, StandardMinorOpcode);
+ AddExtension(DPMSExtensionName, 0, 0,
+ ProcDPMSDispatch, SProcDPMSDispatch,
+ DPMSResetProc, StandardMinorOpcode);
}
/*ARGSUSED*/
@@ -206,7 +206,7 @@ ProcDPMSDisable(client)
REQUEST_SIZE_MATCH(xDPMSDisableReq);
- DPMSSet(DPMSModeOn);
+ DPMSSet(client, DPMSModeOn);
DPMSEnabled = FALSE;
@@ -241,7 +241,7 @@ ProcDPMSForceLevel(client)
return BadValue;
}
- DPMSSet(stuff->level);
+ DPMSSet(client, stuff->level);
return(client->noClientException);
}
diff --git a/Xext/dpmsproc.h b/Xext/dpmsproc.h
index f5485ea79..d57f57318 100644
--- a/Xext/dpmsproc.h
+++ b/Xext/dpmsproc.h
@@ -8,7 +8,9 @@
#ifndef _DPMSPROC_H_
#define _DPMSPROC_H_
-void DPMSSet(int level);
+#include "dixstruct.h"
+
+int DPMSSet(ClientPtr client, int level);
int DPMSGet(int *plevel);
Bool DPMSSupported(void);
diff --git a/Xext/dpmsstubs.c b/Xext/dpmsstubs.c
index 9f99a2d22..fad07bde6 100644
--- a/Xext/dpmsstubs.c
+++ b/Xext/dpmsstubs.c
@@ -46,7 +46,7 @@ int DPMSGet(int *plevel)
return -1;
}
-void DPMSSet(int level)
+int DPMSSet(ClientPtr client, int level)
{
-
+ return Success;
}
diff --git a/Xext/mbuf.c b/Xext/mbuf.c
index e646a7daa..35c8c8988 100644
--- a/Xext/mbuf.c
+++ b/Xext/mbuf.c
@@ -232,7 +232,7 @@ MultibufferExtensionInit()
* create the resource types
*/
MultibufferDrawableResType =
- CreateNewResourceType(MultibufferDrawableDelete)|RC_CACHED|RC_DRAWABLE;
+ CreateNewResourceType(MultibufferDrawableDelete)|RC_DRAWABLE;
MultibufferResType = CreateNewResourceType(MultibufferDelete);
MultibuffersResType = CreateNewResourceType(MultibuffersDelete);
OtherClientResType = CreateNewResourceType(OtherClientDelete);
diff --git a/Xext/mitmisc.c b/Xext/mitmisc.c
index f89ee0c2b..e793d4dc1 100644
--- a/Xext/mitmisc.c
+++ b/Xext/mitmisc.c
@@ -56,9 +56,9 @@ static DISPATCH_PROC(SProcMITSetBugMode);
void
MITMiscExtensionInit(INITARGS)
{
- (void) AddExtension(MITMISCNAME, 0, 0,
- ProcMITDispatch, SProcMITDispatch,
- MITResetProc, StandardMinorOpcode);
+ AddExtension(MITMISCNAME, 0, 0,
+ ProcMITDispatch, SProcMITDispatch,
+ MITResetProc, StandardMinorOpcode);
}
/*ARGSUSED*/
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index d054cf8f1..311a8e716 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -107,8 +107,8 @@ static void PanoramiXResetProc(ExtensionEntry*);
int (* SavedProcVector[256]) (ClientPtr client) = { NULL, };
-static int PanoramiXGCIndex = -1;
-static int PanoramiXScreenIndex = -1;
+static DevPrivateKey PanoramiXGCKey = &PanoramiXGCKey;
+static DevPrivateKey PanoramiXScreenKey = &PanoramiXScreenKey;
typedef struct {
DDXPointRec clipOrg;
@@ -137,8 +137,8 @@ static GCFuncs XineramaGCFuncs = {
};
#define Xinerama_GC_FUNC_PROLOGUE(pGC)\
- PanoramiXGCPtr pGCPriv = \
- (PanoramiXGCPtr) (pGC)->devPrivates[PanoramiXGCIndex].ptr;\
+ PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, PanoramiXGCKey); \
(pGC)->funcs = pGCPriv->wrapFuncs;
#define Xinerama_GC_FUNC_EPILOGUE(pGC)\
@@ -149,8 +149,8 @@ static GCFuncs XineramaGCFuncs = {
static Bool
XineramaCloseScreen (int i, ScreenPtr pScreen)
{
- PanoramiXScreenPtr pScreenPriv =
- (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr;
+ PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->CreateGC = pScreenPriv->CreateGC;
@@ -168,14 +168,14 @@ static Bool
XineramaCreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
- PanoramiXScreenPtr pScreenPriv =
- (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr;
+ PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
Bool ret;
pScreen->CreateGC = pScreenPriv->CreateGC;
if((ret = (*pScreen->CreateGC)(pGC))) {
- PanoramiXGCPtr pGCPriv =
- (PanoramiXGCPtr) pGC->devPrivates[PanoramiXGCIndex].ptr;
+ PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr)
+ dixLookupPrivate(&pGC->devPrivates, PanoramiXGCKey);
pGCPriv->wrapFuncs = pGC->funcs;
pGC->funcs = &XineramaGCFuncs;
@@ -281,8 +281,8 @@ XineramaCopyGC (
unsigned long mask,
GCPtr pGCDst
){
- PanoramiXGCPtr pSrcPriv =
- (PanoramiXGCPtr) pGCSrc->devPrivates[PanoramiXGCIndex].ptr;
+ PanoramiXGCPtr pSrcPriv = (PanoramiXGCPtr)
+ dixLookupPrivate(&pGCSrc->devPrivates, PanoramiXGCKey);
Xinerama_GC_FUNC_PROLOGUE (pGCDst);
if(mask & GCTileStipXOrigin)
@@ -477,20 +477,17 @@ void PanoramiXExtensionInit(int argc, char *argv[])
xcalloc(PanoramiXNumScreens, sizeof(PanoramiXData));
BREAK_IF(!panoramiXdataPtr);
- BREAK_IF((PanoramiXGCIndex = AllocateGCPrivateIndex()) < 0);
- BREAK_IF((PanoramiXScreenIndex = AllocateScreenPrivateIndex()) < 0);
+
+ if (!dixRequestPrivate(PanoramiXGCKey, sizeof(PanoramiXGCRec))) {
+ noPanoramiXExtension = TRUE;
+ return;
+ }
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;
+ dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey,
+ pScreenPriv);
if(!pScreenPriv) {
noPanoramiXExtension = TRUE;
return;
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 4bd525727..f9a579625 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -1039,8 +1039,7 @@ int PanoramiXCopyArea(ClientPtr client)
FOR_NSCREENS_BACKWARD(j) {
stuff->gc = gc->info[j].id;
- VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, pGC, client);
-
+ VALIDATE_DRAWABLE_AND_GC(dst->info[j].id, pDst, DixWriteAccess);
if(drawables[0]->depth != pDst->depth) {
client->errorValue = stuff->dstDrawable;
xfree(data);
@@ -1076,7 +1075,8 @@ int PanoramiXCopyArea(ClientPtr client)
stuff->dstY = dsty - panoramiXdataPtr[j].y;
}
- VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess);
+
if (stuff->dstDrawable != stuff->srcDrawable) {
rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0,
DixReadAccess);
@@ -1185,7 +1185,7 @@ int PanoramiXCopyPlane(ClientPtr client)
stuff->dstY = dsty - panoramiXdataPtr[j].y;
}
- VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess);
if (stuff->dstDrawable != stuff->srcDrawable) {
rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0,
DixReadAccess);
diff --git a/Xext/saver.c b/Xext/saver.c
index 44689fc53..9a6dd7757 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -48,6 +48,7 @@ in this Software without prior written authorization from the X Consortium.
#include "gcstruct.h"
#include "cursorstr.h"
#include "colormapst.h"
+#include "xace.h"
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
@@ -231,10 +232,12 @@ MakeScreenPrivate (
ScreenPtr /* pScreen */
);
-static int ScreenPrivateIndex;
+static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKey;
-#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr)
-#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v);
+#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
+ dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
+#define SetScreenPrivate(s,v) \
+ dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v);
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL)
#define New(t) ((t *) xalloc (sizeof (t)))
@@ -257,14 +260,13 @@ ScreenSaverExtensionInit(INITARGS)
AttrType = CreateNewResourceType(ScreenSaverFreeAttr);
EventType = CreateNewResourceType(ScreenSaverFreeEvents);
SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend);
- ScreenPrivateIndex = AllocateScreenPrivateIndex ();
for (i = 0; i < screenInfo.numScreens; i++)
{
pScreen = screenInfo.screens[i];
SetScreenPrivate (pScreen, NULL);
}
- if (AttrType && EventType && SuspendType && ScreenPrivateIndex != -1 &&
+ if (AttrType && EventType && SuspendType &&
(extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0,
ProcScreenSaverDispatch, SProcScreenSaverDispatch,
ScreenSaverResetProc, StandardMinorOpcode)))
@@ -448,8 +450,8 @@ ScreenSaverFreeAttr (value, id)
pPriv->attr = NULL;
if (pPriv->hasWindow)
{
- SaveScreens (SCREEN_SAVER_FORCER, ScreenSaverReset);
- SaveScreens (SCREEN_SAVER_FORCER, ScreenSaverActive);
+ dixSaveScreens (serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
+ dixSaveScreens (serverClient, SCREEN_SAVER_FORCER, ScreenSaverActive);
}
CheckScreenPrivate (pScreen);
return TRUE;
@@ -782,7 +784,11 @@ ProcScreenSaverQueryInfo (client)
REQUEST_SIZE_MATCH (xScreenSaverQueryInfoReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
- DixUnknownAccess);
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+ rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
+ DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -851,9 +857,15 @@ ProcScreenSaverSelectInput (client)
REQUEST_SIZE_MATCH (xScreenSaverSelectInputReq);
rc = dixLookupDrawable (&pDraw, stuff->drawable, client, 0,
- DixUnknownAccess);
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
+ DixSetAttrAccess);
if (rc != Success)
return rc;
+
if (!setEventMask (pDraw->pScreen, client, stuff->eventMask))
return BadAlloc;
return Success;
@@ -887,12 +899,16 @@ ScreenSaverSetAttributes (ClientPtr client)
REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq);
ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
- DixUnknownAccess);
+ DixGetAttrAccess);
if (ret != Success)
return ret;
pScreen = pDraw->pScreen;
pParent = WindowTable[pScreen->myNum];
+ ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess);
+ if (ret != Success)
+ return ret;
+
len = stuff->length - (sizeof(xScreenSaverSetAttributesReq) >> 2);
if (Ones(stuff->mask) != len)
return BadLength;
@@ -1048,8 +1064,9 @@ ScreenSaverSetAttributes (ClientPtr client)
}
else
{
- pPixmap = (PixmapPtr)LookupIDByType(pixID, RT_PIXMAP);
- if (pPixmap != (PixmapPtr) NULL)
+ ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
+ client, DixReadAccess);
+ if (ret == Success)
{
if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen))
@@ -1063,7 +1080,7 @@ ScreenSaverSetAttributes (ClientPtr client)
}
else
{
- ret = BadPixmap;
+ ret = (ret == BadValue) ? BadPixmap : ret;
client->errorValue = pixID;
goto PatchUp;
}
@@ -1085,8 +1102,9 @@ ScreenSaverSetAttributes (ClientPtr client)
}
else
{
- pPixmap = (PixmapPtr)LookupIDByType(pixID, RT_PIXMAP);
- if (pPixmap)
+ ret = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
+ client, DixReadAccess);
+ if (ret == Success)
{
if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen))
@@ -1100,7 +1118,7 @@ ScreenSaverSetAttributes (ClientPtr client)
}
else
{
- ret = BadPixmap;
+ ret = (ret == BadValue) ? BadPixmap : ret;
client->errorValue = pixID;
goto PatchUp;
}
@@ -1178,10 +1196,11 @@ ScreenSaverSetAttributes (ClientPtr client)
break;
case CWColormap:
cmap = (Colormap) *pVlist;
- pCmap = (ColormapPtr)LookupIDByType(cmap, RT_COLORMAP);
- if (!pCmap)
+ ret = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP,
+ client, DixUseAccess);
+ if (ret != Success)
{
- ret = BadColor;
+ ret = (ret == BadValue) ? BadColor : ret;
client->errorValue = cmap;
goto PatchUp;
}
@@ -1201,10 +1220,11 @@ ScreenSaverSetAttributes (ClientPtr client)
}
else
{
- pCursor = (CursorPtr)LookupIDByType(cursorID, RT_CURSOR);
- if (!pCursor)
+ ret = dixLookupResource((pointer *)&pCursor, cursorID,
+ RT_CURSOR, client, DixUseAccess);
+ if (ret != Success)
{
- ret = BadCursor;
+ ret = (ret == BadValue) ? BadCursor : ret;
client->errorValue = cursorID;
goto PatchUp;
}
@@ -1246,7 +1266,7 @@ ScreenSaverUnsetAttributes (ClientPtr client)
REQUEST_SIZE_MATCH (xScreenSaverUnsetAttributesReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
- DixUnknownAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
pPriv = GetScreenPrivate (pDraw->pScreen);
diff --git a/Xext/security.c b/Xext/security.c
index ba057defd..6aab3a342 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -28,63 +28,50 @@ in this Software without prior written authorization from The Open Group.
#include <dix-config.h>
#endif
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "windowstr.h"
-#include "inputstr.h"
#include "scrnintstr.h"
-#include "gcstruct.h"
#include "colormapst.h"
-#include "propertyst.h"
+#include "privates.h"
+#include "registry.h"
#include "xacestr.h"
#include "securitysrv.h"
#include <X11/extensions/securstr.h>
-#include <assert.h>
-#include <stdarg.h>
#ifdef XAPPGROUP
#include "appgroup.h"
#endif
-#include <stdio.h> /* for file reading operations */
-#include <X11/Xatom.h> /* for XA_STRING */
-
-#ifndef DEFAULTPOLICYFILE
-# define DEFAULTPOLICYFILE NULL
-#endif
-#if defined(WIN32) || defined(__CYGWIN__)
-#include <X11/Xos.h>
-#undef index
-#endif
-
#include "modinit.h"
+/* Extension stuff */
static int SecurityErrorBase; /* first Security error number */
static int SecurityEventBase; /* first Security event number */
-static int securityClientPrivateIndex;
-static int securityExtnsnPrivateIndex;
-/* this is what we store as client security state */
-typedef struct {
- unsigned int trustLevel;
- XID authId;
-} SecurityClientStateRec;
-
-#define STATEVAL(extnsn) \
- ((extnsn)->devPrivates[securityExtnsnPrivateIndex].val)
-#define STATEPTR(client) \
- ((client)->devPrivates[securityClientPrivateIndex].ptr)
-#define TRUSTLEVEL(client) \
- (((SecurityClientStateRec*)STATEPTR(client))->trustLevel)
-#define AUTHID(client) \
- (((SecurityClientStateRec*)STATEPTR(client))->authId)
+RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */
+static RESTYPE RTEventClient;
static CallbackListPtr SecurityValidateGroupCallback = NULL;
-RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */
+/* Private state record */
+static DevPrivateKey stateKey = &stateKey;
-static RESTYPE RTEventClient;
+/* This is what we store as client security state */
+typedef struct {
+ int haveState;
+ unsigned int trustLevel;
+ XID authId;
+} SecurityStateRec;
+
+/* Extensions that untrusted clients shouldn't have access to */
+static char *SecurityUntrustedExtensions[] = {
+ "RandR",
+ "SECURITY",
+ "XFree86-DGA",
+ NULL
+};
+
+/* Access modes that untrusted clients can do to trusted stuff */
+static const Mask SecurityAllowedMask =
+ DixGetAttrAccess | DixListPropAccess | DixGetPropAccess |
+ DixGetFocusAccess | DixListAccess | DixReceiveAccess;
-#define CALLBACK(name) static void \
-name(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
/* SecurityAudit
*
@@ -110,6 +97,51 @@ SecurityAudit(char *format, ...)
va_end(args);
} /* SecurityAudit */
+/*
+ * Performs a Security permission check.
+ */
+static int
+SecurityDoCheck(SecurityStateRec *subj, SecurityStateRec *obj,
+ Mask requested, Mask allowed)
+{
+ if (!subj->haveState || !obj->haveState)
+ return Success;
+ if (subj->trustLevel == XSecurityClientTrusted)
+ return Success;
+ if (obj->trustLevel != XSecurityClientTrusted)
+ return Success;
+ if ((requested | allowed) == allowed)
+ return Success;
+
+ return BadAccess;
+}
+
+/*
+ * Labels initial server objects.
+ */
+static void
+SecurityLabelInitial(void)
+{
+ SecurityStateRec *state;
+
+ /* Do the serverClient */
+ state = dixLookupPrivate(&serverClient->devPrivates, stateKey);
+ state->trustLevel = XSecurityClientTrusted;
+ state->haveState = TRUE;
+}
+
+/*
+ * Looks up a request name
+ */
+static _X_INLINE const char *
+SecurityLookupRequestName(ClientPtr client)
+{
+ int major = ((xReq *)client->requestBuffer)->reqType;
+ int minor = MinorOpcodeOfRequest(client);
+ return LookupRequestName(major, minor);
+}
+
+
#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
/* SecurityDeleteAuthorization
@@ -170,10 +202,12 @@ SecurityDeleteAuthorization(
/* kill all clients using this auth */
for (i = 1; i<currentMaxClients; i++)
- {
- if (clients[i] && (AUTHID(clients[i]) == pAuth->id))
- CloseDownClient(clients[i]);
- }
+ if (clients[i]) {
+ SecurityStateRec *state;
+ state = dixLookupPrivate(&clients[i]->devPrivates, stateKey);
+ if (state->haveState && state->authId == pAuth->id)
+ CloseDownClient(clients[i]);
+ }
SecurityAudit("revoked authorization ID %d\n", pAuth->id);
xfree(pAuth);
@@ -322,12 +356,6 @@ ProcSecurityQueryVersion(
/* REQUEST(xSecurityQueryVersionReq); */
xSecurityQueryVersionReply rep;
- /* paranoia: this "can't happen" because this extension is hidden
- * from untrusted clients, but just in case...
- */
- if (TRUSTLEVEL(client) != XSecurityClientTrusted)
- return BadRequest;
-
REQUEST_SIZE_MATCH(xSecurityQueryVersionReq);
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
@@ -408,12 +436,6 @@ ProcSecurityGenerateAuthorization(
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 (TRUSTLEVEL(client) != XSecurityClientTrusted)
- return BadRequest;
-
/* check request length */
REQUEST_AT_LEAST_SIZE(xSecurityGenerateAuthorizationReq);
@@ -591,12 +613,6 @@ ProcSecurityRevokeAuthorization(
REQUEST(xSecurityRevokeAuthorizationReq);
SecurityAuthorizationPtr pAuth;
- /* paranoia: this "can't happen" because this extension is hidden
- * from untrusted clients, but just in case...
- */
- if (TRUSTLEVEL(client) != XSecurityClientTrusted)
- return BadRequest;
-
REQUEST_SIZE_MATCH(xSecurityRevokeAuthorizationReq);
pAuth = (SecurityAuthorizationPtr)SecurityLookupIDByType(client,
@@ -710,59 +726,6 @@ SwapSecurityAuthorizationRevokedEvent(
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:
@@ -779,162 +742,26 @@ SecurityDetermineEventPropogationLimits(
* An audit message is generated if access is denied.
*/
-CALLBACK(SecurityCheckDeviceAccess)
-{
- XaceDeviceAccessRec *rec = (XaceDeviceAccessRec*)calldata;
- ClientPtr client = rec->client;
- DeviceIntPtr dev = rec->dev;
- Bool fromRequest = rec->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 (TRUSTLEVEL(client) == XSecurityClientTrusted)
- return;
-
- /* device security other than keyboard is not implemented yet */
- if (dev != inputInfo.keyboard)
- return;
-
- /* 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);
- rec->rval = FALSE;
- return;
- default:
- break;
- }
- }
-
- untrusted_got_event = FALSE;
- found_event_window = FALSE;
-
- if (dev->grab)
- {
- untrusted_got_event =
- (TRUSTLEVEL(rClient(dev->grab)) != 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 (TRUSTLEVEL(client) != 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 (TRUSTLEVEL(client) != 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);
- rec->rval = FALSE;
- }
- return;
-} /* 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)
+static void
+SecurityDevice(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
- 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;
- }
+ XaceDeviceAccessRec *rec = calldata;
+ SecurityStateRec *subj, *obj;
+ Mask requested = rec->access_mode;
+ Mask allowed = SecurityAllowedMask;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&serverClient->devPrivates, stateKey);
+
+ if (SecurityDoCheck(subj, obj, requested, allowed) != Success) {
+ SecurityAudit("Security denied client %d keyboard access on request "
+ "%s\n", rec->client->index,
+ SecurityLookupRequestName(rec->client));
+ rec->status = BadAccess;
}
- return NULL;
-} /* SecurityAuditResourceIDAccess */
-
+}
-/* SecurityCheckResourceIDAccess
+/* SecurityResource
*
* This function gets plugged into client->CheckAccess and is called from
* SecurityLookupIDByType/Class to determine if the client can access the
@@ -955,867 +782,246 @@ SecurityAuditResourceIDAccess(
* Disallowed resource accesses are audited.
*/
-CALLBACK(SecurityCheckResourceIDAccess)
+static void
+SecurityResource(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
- XaceResourceAccessRec *rec = (XaceResourceAccessRec*)calldata;
- ClientPtr client = rec->client;
- XID id = rec->id;
- RESTYPE rtype = rec->rtype;
- Mask access_mode = rec->access_mode;
- pointer rval = rec->res;
- int cid, reqtype;
-
- if (TRUSTLEVEL(client) == XSecurityClientTrusted ||
- DixUnknownAccess == access_mode)
- return; /* for compatibility, we have to allow access */
-
- cid = CLIENT_ID(id);
- reqtype = ((xReq *)client->requestBuffer)->reqType;
- 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;
- default:
- break;
+ XaceResourceAccessRec *rec = calldata;
+ SecurityStateRec *subj, *obj;
+ int cid = CLIENT_ID(rec->id);
+ Mask requested = rec->access_mode;
+ Mask allowed = SecurityAllowedMask;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&clients[cid]->devPrivates, stateKey);
+
+ /* special checks for server-owned resources */
+ if (cid == 0) {
+ if (rec->rtype & RC_DRAWABLE)
+ /* additional operations allowed on root windows */
+ allowed |= DixReadAccess|DixSendAccess;
+
+ else if (rec->rtype == RT_COLORMAP)
+ /* allow access to default colormaps */
+ allowed = requested;
}
- 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 (TRUSTLEVEL(client) == TRUSTLEVEL(clients[cid])
+ if (SecurityDoCheck(subj, obj, requested, allowed) == Success)
+ return;
+
#ifdef XAPPGROUP
- || (RT_COLORMAP == rtype &&
- XagDefaultColormap (client) == (Colormap) id)
+ if (rec->id == XagDefaultColormap(rec->client))
+ return;
#endif
- )
- return;
- else
- goto deny;
- }
- 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 */
- goto deny;
- }
- 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;
- }
- goto deny;
- } /* case X_ChangeWindowAttributes on root */
-
- default:
- {
- /* others not allowed */
- goto deny;
- }
- }
- } /* end server-owned window or drawable */
- else if (SecurityAuthorizationResType == rtype)
- {
- SecurityAuthorizationPtr pAuth = (SecurityAuthorizationPtr)rval;
- if (pAuth->trustLevel != TRUSTLEVEL(client))
- goto deny;
- }
- else if (RT_COLORMAP != rtype)
- { /* don't allow anything else besides colormaps */
- goto deny;
- }
- }
- return;
- deny:
- SecurityAuditResourceIDAccess(client, id);
- rec->rval = FALSE; /* deny access */
-} /* 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 TRUSTLEVEL(client).
- *
- * 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.
- */
-
-CALLBACK(SecurityClientStateCallback)
-{
- NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
- ClientPtr client = pci->client;
-
- switch (client->clientState)
- {
- case ClientStateInitial:
- TRUSTLEVEL(client) = XSecurityClientTrusted;
- AUTHID(client) = None;
- break;
-
- case ClientStateRunning:
- {
- XID authId = AuthorizationIDOfClient(client);
- SecurityAuthorizationPtr pAuth;
-
- TRUSTLEVEL(client) = XSecurityClientTrusted;
- AUTHID(client) = 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);
- }
- TRUSTLEVEL(client) = pAuth->trustLevel;
- }
- break;
- }
- case ClientStateGone:
- case ClientStateRetained: /* client disconnected */
- {
- SecurityAuthorizationPtr pAuth;
-
- /* client may not have any state (bad authorization) */
- if (!STATEPTR(client))
- break;
-
- pAuth = (SecurityAuthorizationPtr)LookupIDByType(AUTHID(client),
- SecurityAuthorizationResType);
- if (pAuth)
- { /* it is a generated authorization */
- pAuth->refcnt--;
- if (pAuth->refcnt == 0)
- {
- SecurityStartAuthorizationTimer(pAuth);
- }
- }
- break;
- }
- default: break;
- }
-} /* SecurityClientStateCallback */
-
-CALLBACK(SecurityCheckDrawableAccess)
-{
- XaceDrawableAccessRec *rec = (XaceDrawableAccessRec*)calldata;
-
- if (TRUSTLEVEL(rec->client) != XSecurityClientTrusted)
- rec->rval = FALSE;
+ SecurityAudit("Security: denied client %d access to resource 0x%x "
+ "of client %d on request %s\n", rec->client->index, rec->id,
+ cid, SecurityLookupRequestName(rec->client));
+ rec->status = BadAccess; /* deny access */
}
-CALLBACK(SecurityCheckMapAccess)
-{
- XaceMapAccessRec *rec = (XaceMapAccessRec*)calldata;
- WindowPtr pWin = rec->pWin;
-
- if (STATEPTR(rec->client) &&
- (TRUSTLEVEL(rec->client) != XSecurityClientTrusted) &&
- (pWin->drawable.class == InputOnly) &&
- pWin->parent && pWin->parent->parent &&
- (TRUSTLEVEL(wClient(pWin->parent)) == XSecurityClientTrusted))
-
- rec->rval = FALSE;
-}
-CALLBACK(SecurityCheckBackgrndAccess)
+static void
+SecurityExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
- XaceMapAccessRec *rec = (XaceMapAccessRec*)calldata;
-
- if (TRUSTLEVEL(rec->client) != XSecurityClientTrusted)
- rec->rval = FALSE;
+ XaceExtAccessRec *rec = calldata;
+ SecurityStateRec *subj;
+ int i = 0;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+
+ if (subj->haveState && subj->trustLevel != XSecurityClientTrusted)
+ while (SecurityUntrustedExtensions[i])
+ if (!strcmp(SecurityUntrustedExtensions[i++], rec->ext->name)) {
+ SecurityAudit("Security: denied client %d access to extension "
+ "%s on request %s\n",
+ rec->client->index, rec->ext->name,
+ SecurityLookupRequestName(rec->client));
+ rec->status = BadAccess;
+ return;
+ }
}
-CALLBACK(SecurityCheckExtAccess)
+static void
+SecurityServer(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
- XaceExtAccessRec *rec = (XaceExtAccessRec*)calldata;
-
- if ((TRUSTLEVEL(rec->client) != XSecurityClientTrusted) &&
- !STATEVAL(rec->ext))
-
- rec->rval = FALSE;
-}
+ XaceServerAccessRec *rec = calldata;
+ SecurityStateRec *subj, *obj;
+ Mask requested = rec->access_mode;
+ Mask allowed = SecurityAllowedMask;
-CALLBACK(SecurityCheckHostlistAccess)
-{
- XaceHostlistAccessRec *rec = (XaceHostlistAccessRec*)calldata;
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&serverClient->devPrivates, stateKey);
- if (TRUSTLEVEL(rec->client) != XSecurityClientTrusted)
- {
- rec->rval = FALSE;
- if (rec->access_mode == DixWriteAccess)
- SecurityAudit("client %d attempted to change host access\n",
- rec->client->index);
- else
- SecurityAudit("client %d attempted to list hosts\n",
- rec->client->index);
+ if (SecurityDoCheck(subj, obj, requested, allowed) != Success) {
+ SecurityAudit("Security: denied client %d access to server "
+ "configuration request %s\n", rec->client->index,
+ SecurityLookupRequestName(rec->client));
+ rec->status = BadAccess;
}
}
-CALLBACK(SecurityDeclareExtSecure)
-{
- XaceDeclareExtSecureRec *rec = (XaceDeclareExtSecureRec*)calldata;
-
- /* security state for extensions is simply a boolean trust value */
- STATEVAL(rec->ext) = rec->secure;
-}
-
-/**********************************************************************/
-
-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 = XaceErrorOperation;
-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)
+SecurityClient(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
- while (PropertyAccessList)
- {
- PropertyAccessPtr freeit = PropertyAccessList;
- PropertyAccessList = PropertyAccessList->next;
- xfree(freeit);
+ XaceClientAccessRec *rec = calldata;
+ SecurityStateRec *subj, *obj;
+ Mask requested = rec->access_mode;
+ Mask allowed = SecurityAllowedMask;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&rec->target->devPrivates, stateKey);
+
+ if (SecurityDoCheck(subj, obj, requested, allowed) != Success) {
+ SecurityAudit("Security: denied client %d access to client %d on "
+ "request %s\n", rec->client->index, rec->target->index,
+ SecurityLookupRequestName(rec->client));
+ rec->status = BadAccess;
}
-} /* SecurityFreePropertyAccessList */
-
-#define SecurityIsWhitespace(c) ( (c == ' ') || (c == '\t') || (c == '\n') )
-
-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 = XaceIgnoreOperation; break;
- case 'a': action = XaceAllowOperation; break;
- case 'e': action = XaceErrorOperation; 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;
+static void
+SecurityProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XacePropertyAccessRec *rec = calldata;
+ SecurityStateRec *subj, *obj;
+ ATOM name = rec->pProp->propertyName;
+ Mask requested = rec->access_mode;
+ Mask allowed = SecurityAllowedMask | DixReadAccess;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
+
+ if (SecurityDoCheck(subj, obj, requested, allowed) != Success) {
+ SecurityAudit("Security: denied client %d access to property %s "
+ "(atom 0x%x) window 0x%x of client %d on request %s\n",
+ rec->client->index, NameForAtom(name), name,
+ rec->pWin->drawable.id, wClient(rec->pWin)->index,
+ SecurityLookupRequestName(rec->client));
+ rec->status = BadAccess;
}
- return TRUE;
-} /* SecurityParsePropertyAccessRule */
-
-static char **SecurityPolicyStrings = NULL;
-static int nSecurityPolicyStrings = 0;
+}
-static Bool
-SecurityParseSitePolicy(
- char *p)
+static void
+SecuritySend(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
- 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;
+ XaceSendAccessRec *rec = calldata;
+ SecurityStateRec *subj, *obj;
- return TRUE;
+ if (rec->client) {
+ int i;
-} /* SecurityParseSitePolicy */
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
+ if (SecurityDoCheck(subj, obj, DixSendAccess, 0) == Success)
+ return;
-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;
+ for (i = 0; i < rec->count; i++)
+ if (rec->events[i].u.u.type != UnmapNotify &&
+ rec->events[i].u.u.type != ConfigureRequest &&
+ rec->events[i].u.u.type != ClientMessage) {
+
+ SecurityAudit("Security: denied client %d from sending event "
+ "of type %s to window 0x%x of client %d\n",
+ rec->client->index, rec->pWin->drawable.id,
+ wClient(rec->pWin)->index,
+ LookupEventName(rec->events[i].u.u.type));
+ rec->status = BadAccess;
+ return;
+ }
}
-} /* SecurityFreeSitePolicyStrings */
-
+}
static void
-SecurityLoadPropertyAccessList(void)
+SecurityReceive(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
- FILE *f;
- int lineNumber = 0;
+ XaceReceiveAccessRec *rec = calldata;
+ SecurityStateRec *subj, *obj;
- SecurityMaxPropertyName = 0;
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&wClient(rec->pWin)->devPrivates, stateKey);
- if (!SecurityPolicyFile)
- return;
-
- f = fopen(SecurityPolicyFile, "r");
- if (!f)
- {
- ErrorF("error opening security policy file %s\n",
- SecurityPolicyFile);
+ if (SecurityDoCheck(subj, obj, DixReceiveAccess, 0) == Success)
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 */
+ SecurityAudit("Security: denied client %d from receiving an event "
+ "sent to window 0x%x of client %d\n",
+ rec->client->index, rec->pWin->drawable.id,
+ wClient(rec->pWin)->index);
+ rec->status = BadAccess;
+}
+/* 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 TRUSTLEVEL(client).
+ *
+ * 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 Bool
-SecurityMatchString(
- char *ws,
- char *cs)
+static void
+SecurityClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
{
- while (*ws && *cs)
- {
- if (*ws == '*')
- {
- Bool match = FALSE;
- ws++;
- while (!(match = SecurityMatchString(ws, cs)) && *cs)
- {
- cs++;
- }
- return match;
- }
- else if (*ws == *cs)
- {
- ws++;
- cs++;
- }
- else break;
- }
- return ( ( (*ws == '\0') || ((*ws == '*') && *(ws+1) == '\0') )
- && (*cs == '\0') );
-} /* SecurityMatchString */
-
-#ifdef PROPDEBUG
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif
+ NewClientInfoRec *pci = calldata;
+ SecurityStateRec *state;
+ SecurityAuthorizationPtr pAuth;
+ int rc;
+ state = dixLookupPrivate(&pci->client->devPrivates, stateKey);
-CALLBACK(SecurityCheckPropertyAccess)
-{
- XacePropertyAccessRec *rec = (XacePropertyAccessRec*)calldata;
- ClientPtr client = rec->client;
- WindowPtr pWin = rec->pWin;
- ATOM propertyName = rec->propertyName;
- Mask access_mode = rec->access_mode;
- PropertyAccessPtr pacl;
- char action = SecurityDefaultAction;
-
- /* if client trusted or window untrusted, allow operation */
-
- if ( (TRUSTLEVEL(client) == XSecurityClientTrusted) ||
- (TRUSTLEVEL(wClient(pWin)) != XSecurityClientTrusted) )
- return;
+ switch (pci->client->clientState) {
+ case ClientStateInitial:
+ state->trustLevel = XSecurityClientTrusted;
+ state->authId = None;
+ state->haveState = TRUE;
+ break;
-#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;
+ case ClientStateRunning:
+ state->authId = AuthorizationIDOfClient(pci->client);
+ rc = dixLookupResource((pointer *)&pAuth, state->authId,
+ SecurityAuthorizationResType, serverClient,
+ DixGetAttrAccess);
+ if (rc == Success) {
+ /* it is a generated authorization */
+ pAuth->refcnt++;
+ if (pAuth->refcnt == 1 && pAuth->timer)
+ TimerCancel(pAuth->timer);
+
+ state->trustLevel = pAuth->trustLevel;
}
- }
-#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;
+ break;
- /* pacl->name == propertyName, so see if it applies to this window */
+ case ClientStateGone:
+ case ClientStateRetained:
+ rc = dixLookupResource((pointer *)&pAuth, state->authId,
+ SecurityAuthorizationResType, serverClient,
+ DixGetAttrAccess);
+ if (rc == Success) {
+ /* it is a generated authorization */
+ pAuth->refcnt--;
+ if (pAuth->refcnt == 0)
+ SecurityStartAuthorizationTimer(pAuth);
+ }
+ break;
- 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 = XaceAllowOperation;
- if (access_mode & DixReadAccess)
- action = max(action, pacl->readAction);
- if (access_mode & DixWriteAccess)
- action = max(action, pacl->writeAction);
- if (access_mode & DixDestroyAccess)
- action = max(action, pacl->destroyAction);
- break;
- } /* end for each pacl */
- } /* end if propertyName <= SecurityMaxPropertyName */
-
- if (XaceAllowOperation != action)
- { /* audit the access violation */
- int cid = CLIENT_ID(pWin->drawable.id);
- int reqtype = ((xReq *)client->requestBuffer)->reqType;
- char *actionstr = (XaceIgnoreOperation == 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);
+ default:
+ break;
}
- /* return codes increase with strictness */
- if (action > rec->rval)
- rec->rval = action;
-} /* SecurityCheckPropertyAccess */
-
+}
/* SecurityResetProc
*
@@ -1832,66 +1038,19 @@ 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 */
-
-
-/* SecurityExtensionSetup
- *
- * Arguments: none.
- *
- * Returns: nothing.
- *
- * Side Effects:
- * Sets up the Security extension if possible.
- * This function contains things that need to be done
- * before any other extension init functions get called.
- */
-
-void
-SecurityExtensionSetup(INITARGS)
-{
- /* Allocate the client private index */
- securityClientPrivateIndex = AllocateClientPrivateIndex();
- if (!AllocateClientPrivate(securityClientPrivateIndex,
- sizeof (SecurityClientStateRec)))
- FatalError("SecurityExtensionSetup: Can't allocate client private.\n");
-
- /* Allocate the extension private index */
- securityExtnsnPrivateIndex = AllocateExtensionPrivateIndex();
- if (!AllocateExtensionPrivate(securityExtnsnPrivateIndex, 0))
- FatalError("SecurityExtensionSetup: Can't allocate extnsn private.\n");
-
- /* register callbacks */
-#define XaceRC XaceRegisterCallback
- XaceRC(XACE_RESOURCE_ACCESS, SecurityCheckResourceIDAccess, NULL);
- XaceRC(XACE_DEVICE_ACCESS, SecurityCheckDeviceAccess, NULL);
- XaceRC(XACE_PROPERTY_ACCESS, SecurityCheckPropertyAccess, NULL);
- XaceRC(XACE_DRAWABLE_ACCESS, SecurityCheckDrawableAccess, NULL);
- XaceRC(XACE_MAP_ACCESS, SecurityCheckMapAccess, NULL);
- XaceRC(XACE_BACKGRND_ACCESS, SecurityCheckBackgrndAccess, NULL);
- XaceRC(XACE_EXT_DISPATCH, SecurityCheckExtAccess, NULL);
- XaceRC(XACE_EXT_ACCESS, SecurityCheckExtAccess, NULL);
- XaceRC(XACE_HOSTLIST_ACCESS, SecurityCheckHostlistAccess, NULL);
- XaceRC(XACE_DECLARE_EXT_SECURE, SecurityDeclareExtSecure, NULL);
-} /* SecurityExtensionSetup */
+ /* Unregister callbacks */
+ DeleteCallback(&ClientStateCallback, SecurityClientState, NULL);
+
+ XaceDeleteCallback(XACE_EXT_DISPATCH, SecurityExtension, NULL);
+ XaceDeleteCallback(XACE_RESOURCE_ACCESS, SecurityResource, NULL);
+ XaceDeleteCallback(XACE_DEVICE_ACCESS, SecurityDevice, NULL);
+ XaceDeleteCallback(XACE_PROPERTY_ACCESS, SecurityProperty, NULL);
+ XaceDeleteCallback(XACE_SEND_ACCESS, SecuritySend, NULL);
+ XaceDeleteCallback(XACE_RECEIVE_ACCESS, SecurityReceive, NULL);
+ XaceDeleteCallback(XACE_CLIENT_ACCESS, SecurityClient, NULL);
+ XaceDeleteCallback(XACE_EXT_ACCESS, SecurityExtension, NULL);
+ XaceDeleteCallback(XACE_SERVER_ACCESS, SecurityServer, NULL);
+}
/* SecurityExtensionInit
@@ -1908,6 +1067,7 @@ void
SecurityExtensionInit(INITARGS)
{
ExtensionEntry *extEntry;
+ int ret = TRUE;
SecurityAuthorizationResType =
CreateNewResourceType(SecurityDeleteAuthorization);
@@ -1920,9 +1080,27 @@ SecurityExtensionInit(INITARGS)
RTEventClient |= RC_NEVERRETAIN;
- if (!AddCallback(&ClientStateCallback, SecurityClientStateCallback, NULL))
- return;
+ /* Allocate the private storage */
+ if (!dixRequestPrivate(stateKey, sizeof(SecurityStateRec)))
+ FatalError("SecurityExtensionSetup: Can't allocate client private.\n");
+
+ /* Register callbacks */
+ ret &= AddCallback(&ClientStateCallback, SecurityClientState, NULL);
+
+ ret &= XaceRegisterCallback(XACE_EXT_DISPATCH, SecurityExtension, NULL);
+ ret &= XaceRegisterCallback(XACE_RESOURCE_ACCESS, SecurityResource, NULL);
+ ret &= XaceRegisterCallback(XACE_DEVICE_ACCESS, SecurityDevice, NULL);
+ ret &= XaceRegisterCallback(XACE_PROPERTY_ACCESS, SecurityProperty, NULL);
+ ret &= XaceRegisterCallback(XACE_SEND_ACCESS, SecuritySend, NULL);
+ ret &= XaceRegisterCallback(XACE_RECEIVE_ACCESS, SecurityReceive, NULL);
+ ret &= XaceRegisterCallback(XACE_CLIENT_ACCESS, SecurityClient, NULL);
+ ret &= XaceRegisterCallback(XACE_EXT_ACCESS, SecurityExtension, NULL);
+ ret &= XaceRegisterCallback(XACE_SERVER_ACCESS, SecurityServer, NULL);
+ if (!ret)
+ FatalError("SecurityExtensionSetup: Failed to register callbacks\n");
+
+ /* Add extension to server */
extEntry = AddExtension(SECURITY_EXTENSION_NAME,
XSecurityNumberEvents, XSecurityNumberErrors,
ProcSecurityDispatch, SProcSecurityDispatch,
@@ -1934,6 +1112,6 @@ SecurityExtensionInit(INITARGS)
EventSwapVector[SecurityEventBase + XSecurityAuthorizationRevoked] =
(EventSwapPtr)SwapSecurityAuthorizationRevokedEvent;
- SecurityLoadPropertyAccessList();
-
-} /* SecurityExtensionInit */
+ /* Label objects that were created before we could register ourself */
+ SecurityLabelInitial();
+}
diff --git a/Xext/securitysrv.h b/Xext/securitysrv.h
index 67d864e2e..f4f3e32ae 100644
--- a/Xext/securitysrv.h
+++ b/Xext/securitysrv.h
@@ -77,13 +77,7 @@ typedef struct {
Bool valid; /* did anyone recognize it? if so, set to TRUE */
} SecurityValidateGroupInfoRec;
-extern int XSecurityOptions(int argc, char **argv, int i);
-
/* Give this value or higher to the -audit option to get security messages */
#define SECURITY_AUDIT_LEVEL 4
-#define SECURITY_POLICY_FILE_VERSION "version-1"
-
-extern char **SecurityGetSitePolicyStrings(int *n);
-
#endif /* _SECURITY_SRV_H */
diff --git a/Xext/shape.c b/Xext/shape.c
index 9c765f22e..2f1baf917 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -317,7 +317,7 @@ ProcShapeRectangles (client)
REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq);
UpdateCurrentTime();
- rc = dixLookupWindow(&pWin, stuff->dest, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess);
if (rc != Success)
return rc;
switch (stuff->destKind) {
@@ -417,7 +417,7 @@ ProcShapeMask (client)
REQUEST_SIZE_MATCH (xShapeMaskReq);
UpdateCurrentTime();
- rc = dixLookupWindow(&pWin, stuff->dest, client, DixWriteAccess);
+ rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess);
if (rc != Success)
return rc;
switch (stuff->destKind) {
@@ -438,10 +438,10 @@ ProcShapeMask (client)
if (stuff->src == None)
srcRgn = 0;
else {
- pPixmap = (PixmapPtr) SecurityLookupIDByType(client, stuff->src,
- RT_PIXMAP, DixReadAccess);
- if (!pPixmap)
- return BadPixmap;
+ rc = dixLookupResource((pointer *)&pPixmap, stuff->src, RT_PIXMAP,
+ client, DixReadAccess);
+ if (rc != Success)
+ return (rc == BadValue) ? BadPixmap : rc;
if (pPixmap->drawable.pScreen != pScreen ||
pPixmap->drawable.depth != 1)
return BadMatch;
@@ -525,7 +525,7 @@ ProcShapeCombine (client)
REQUEST_SIZE_MATCH (xShapeCombineReq);
UpdateCurrentTime();
- rc = dixLookupWindow(&pDestWin, stuff->dest, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pDestWin, stuff->dest, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (!pDestWin->optional)
@@ -546,7 +546,7 @@ ProcShapeCombine (client)
}
pScreen = pDestWin->drawable.pScreen;
- rc = dixLookupWindow(&pSrcWin, stuff->src, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pSrcWin, stuff->src, client, DixGetAttrAccess);
if (rc != Success)
return rc;
switch (stuff->srcKind) {
@@ -645,7 +645,7 @@ ProcShapeOffset (client)
REQUEST_SIZE_MATCH (xShapeOffsetReq);
UpdateCurrentTime();
- rc = dixLookupWindow(&pWin, stuff->dest, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess);
if (rc != Success)
return rc;
switch (stuff->destKind) {
@@ -710,7 +710,7 @@ ProcShapeQueryExtents (client)
RegionPtr region;
REQUEST_SIZE_MATCH (xShapeQueryExtentsReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep.type = X_Reply;
@@ -820,7 +820,7 @@ ProcShapeSelectInput (client)
int rc;
REQUEST_SIZE_MATCH (xShapeSelectInputReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (rc != Success)
return rc;
pHead = (ShapeEventPtr *)SecurityLookupIDByType(client,
@@ -993,7 +993,7 @@ ProcShapeInputSelected (client)
register int n;
REQUEST_SIZE_MATCH (xShapeInputSelectedReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
pHead = (ShapeEventPtr *) SecurityLookupIDByType(client,
@@ -1035,7 +1035,7 @@ ProcShapeGetRectangles (client)
register int n;
REQUEST_SIZE_MATCH(xShapeGetRectanglesReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
switch (stuff->kind) {
diff --git a/Xext/shm.c b/Xext/shm.c
index 5937a0358..e3d7a23ff 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -58,6 +58,7 @@ in this Software without prior written authorization from The Open Group.
#include "extnsionst.h"
#include "servermd.h"
#include "shmint.h"
+#include "xace.h"
#define _XSHM_SERVER_
#include <X11/extensions/shmstr.h>
#include <X11/Xfuncproto.h>
@@ -146,7 +147,7 @@ static int pixmapFormat;
static int shmPixFormat[MAXSCREENS];
static ShmFuncsPtr shmFuncs[MAXSCREENS];
static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS];
-static int shmPixmapPrivate;
+static DevPrivateKey shmPixmapPrivate = &shmPixmapPrivate;
static ShmFuncs miFuncs = {NULL, miShmPutImage};
static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage};
@@ -256,20 +257,11 @@ ShmExtensionInit(INITARGS)
if (!pixmapFormat)
pixmapFormat = ZPixmap;
if (sharedPixmaps)
- {
for (i = 0; i < screenInfo.numScreens; i++)
{
destroyPixmap[i] = screenInfo.screens[i]->DestroyPixmap;
screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap;
}
- shmPixmapPrivate = AllocatePixmapPrivateIndex();
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- if (!AllocatePixmapPrivate(screenInfo.screens[i],
- shmPixmapPrivate, 0))
- return;
- }
- }
}
ShmSegType = CreateNewResourceType(ShmDetachSegment);
if (ShmSegType &&
@@ -322,7 +314,8 @@ ShmDestroyPixmap (PixmapPtr pPixmap)
if (pPixmap->refcnt == 1)
{
ShmDescPtr shmdesc;
- shmdesc = (ShmDescPtr) pPixmap->devPrivates[shmPixmapPrivate].ptr;
+ shmdesc = (ShmDescPtr)dixLookupPrivate(&pPixmap->devPrivates,
+ shmPixmapPrivate);
if (shmdesc)
ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id);
}
@@ -815,7 +808,7 @@ CreatePmap:
shmdesc->addr + stuff->offset);
if (pMap) {
- pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc;
+ dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = newPix->info[j].id;
@@ -855,7 +848,7 @@ ProcShmPutImage(client)
REQUEST(xShmPutImageReq);
REQUEST_SIZE_MATCH(xShmPutImageReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client);
if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse))
return BadValue;
@@ -968,7 +961,7 @@ ProcShmGetImage(client)
return(BadValue);
}
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
- DixUnknownAccess);
+ DixReadAccess);
if (rc != Success)
return rc;
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
@@ -1100,7 +1093,7 @@ ProcShmCreatePixmap(client)
return BadImplementation;
LEGAL_NEW_RESOURCE(stuff->pid, client);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY,
- DixUnknownAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -1129,7 +1122,13 @@ CreatePmap:
shmdesc->addr + stuff->offset);
if (pMap)
{
- pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc;
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP,
+ pMap, RT_NONE, NULL, DixCreateAccess);
+ if (rc != Success) {
+ pDraw->pScreen->DestroyPixmap(pMap);
+ return rc;
+ }
+ dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;
@@ -1137,6 +1136,7 @@ CreatePmap:
{
return(client->noClientException);
}
+ pDraw->pScreen->DestroyPixmap(pMap);
}
return (BadAlloc);
}
diff --git a/Xext/sync.c b/Xext/sync.c
index e87e0bd24..10d448106 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -433,18 +433,18 @@ SyncInitTrigger(client, pTrigger, counter, changes)
Mask changes;
{
SyncCounter *pCounter = pTrigger->pCounter;
- int status;
+ int rc;
Bool newcounter = FALSE;
if (changes & XSyncCACounter)
{
if (counter == None)
pCounter = NULL;
- else if (!(pCounter = (SyncCounter *)SecurityLookupIDByType(
- client, counter, RTCounter, DixReadAccess)))
+ else if (Success != (rc = dixLookupResource((pointer *)&pCounter,
+ counter, RTCounter, client, DixReadAccess)))
{
client->errorValue = counter;
- return SyncErrorBase + XSyncBadCounter;
+ return (rc == BadValue) ? SyncErrorBase + XSyncBadCounter : rc;
}
if (pCounter != pTrigger->pCounter)
{ /* new counter for trigger */
@@ -526,8 +526,8 @@ SyncInitTrigger(client, pTrigger, counter, changes)
*/
if (newcounter)
{
- if ((status = SyncAddTriggerToCounter(pTrigger)) != Success)
- return status;
+ if ((rc = SyncAddTriggerToCounter(pTrigger)) != Success)
+ return rc;
}
else if (IsSystemCounter(pCounter))
{
@@ -1465,7 +1465,7 @@ ProcSyncSetPriority(client)
priorityclient = client;
else {
rc = dixLookupClient(&priorityclient, stuff->id, client,
- DixUnknownAccess);
+ DixSetAttrAccess);
if (rc != Success)
return rc;
}
@@ -1502,7 +1502,7 @@ ProcSyncGetPriority(client)
priorityclient = client;
else {
rc = dixLookupClient(&priorityclient, stuff->id, client,
- DixUnknownAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
}
diff --git a/Xext/xace.c b/Xext/xace.c
index b4e0eee5f..9f8a8cc75 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -22,9 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
#include <stdarg.h>
-#include "windowstr.h"
#include "scrnintstr.h"
-#include "gcstruct.h"
#include "xacestr.h"
#include "modinit.h"
@@ -81,95 +79,117 @@ int XaceHook(int hook, ...)
va_arg(ap, ClientPtr),
va_arg(ap, XID),
va_arg(ap, RESTYPE),
- va_arg(ap, Mask),
va_arg(ap, pointer),
- TRUE /* default allow */
+ va_arg(ap, RESTYPE),
+ va_arg(ap, pointer),
+ va_arg(ap, Mask),
+ Success /* default allow */
};
calldata = &rec;
- prv = &rec.rval;
+ prv = &rec.status;
break;
}
case XACE_DEVICE_ACCESS: {
XaceDeviceAccessRec rec = {
va_arg(ap, ClientPtr),
va_arg(ap, DeviceIntPtr),
- va_arg(ap, Bool),
- TRUE /* default allow */
+ va_arg(ap, Mask),
+ Success /* default allow */
};
calldata = &rec;
- prv = &rec.rval;
+ prv = &rec.status;
break;
}
case XACE_PROPERTY_ACCESS: {
XacePropertyAccessRec rec = {
va_arg(ap, ClientPtr),
va_arg(ap, WindowPtr),
- va_arg(ap, Atom),
+ va_arg(ap, PropertyPtr),
va_arg(ap, Mask),
- XaceAllowOperation /* default allow */
+ Success /* default allow */
};
calldata = &rec;
- prv = &rec.rval;
+ prv = &rec.status;
break;
}
- case XACE_DRAWABLE_ACCESS: {
- XaceDrawableAccessRec rec = {
+ case XACE_SEND_ACCESS: {
+ XaceSendAccessRec rec = {
va_arg(ap, ClientPtr),
- va_arg(ap, DrawablePtr),
- TRUE /* default allow */
+ va_arg(ap, DeviceIntPtr),
+ va_arg(ap, WindowPtr),
+ va_arg(ap, xEventPtr),
+ va_arg(ap, int),
+ Success /* default allow */
};
calldata = &rec;
- prv = &rec.rval;
+ prv = &rec.status;
break;
}
- case XACE_MAP_ACCESS:
- case XACE_BACKGRND_ACCESS: {
- XaceMapAccessRec rec = {
+ case XACE_RECEIVE_ACCESS: {
+ XaceReceiveAccessRec rec = {
va_arg(ap, ClientPtr),
va_arg(ap, WindowPtr),
- TRUE /* default allow */
+ va_arg(ap, xEventPtr),
+ va_arg(ap, int),
+ Success /* default allow */
};
calldata = &rec;
- prv = &rec.rval;
+ prv = &rec.status;
+ break;
+ }
+ case XACE_CLIENT_ACCESS: {
+ XaceClientAccessRec rec = {
+ va_arg(ap, ClientPtr),
+ va_arg(ap, ClientPtr),
+ va_arg(ap, Mask),
+ Success /* default allow */
+ };
+ calldata = &rec;
+ prv = &rec.status;
break;
}
- case XACE_EXT_DISPATCH:
case XACE_EXT_ACCESS: {
XaceExtAccessRec rec = {
va_arg(ap, ClientPtr),
va_arg(ap, ExtensionEntry*),
- TRUE /* default allow */
+ DixGetAttrAccess,
+ Success /* default allow */
};
calldata = &rec;
- prv = &rec.rval;
+ prv = &rec.status;
break;
}
- case XACE_HOSTLIST_ACCESS: {
- XaceHostlistAccessRec rec = {
+ case XACE_SERVER_ACCESS: {
+ XaceServerAccessRec rec = {
va_arg(ap, ClientPtr),
va_arg(ap, Mask),
- TRUE /* default allow */
+ Success /* default allow */
};
calldata = &rec;
- prv = &rec.rval;
+ prv = &rec.status;
break;
}
- case XACE_SITE_POLICY: {
- XaceSitePolicyRec rec = {
- va_arg(ap, char*),
- va_arg(ap, int),
- FALSE /* default unrecognized */
+ case XACE_SELECTION_ACCESS: {
+ XaceSelectionAccessRec rec = {
+ va_arg(ap, ClientPtr),
+ va_arg(ap, Atom),
+ va_arg(ap, Mask),
+ Success /* default allow */
};
calldata = &rec;
- prv = &rec.rval;
+ prv = &rec.status;
break;
}
- case XACE_DECLARE_EXT_SECURE: {
- XaceDeclareExtSecureRec rec = {
- va_arg(ap, ExtensionEntry*),
- va_arg(ap, Bool)
+ case XACE_SCREEN_ACCESS:
+ case XACE_SCREENSAVER_ACCESS: {
+ XaceScreenAccessRec rec = {
+ va_arg(ap, ClientPtr),
+ va_arg(ap, ScreenPtr),
+ va_arg(ap, Mask),
+ Success /* default allow */
};
calldata = &rec;
+ prv = &rec.status;
break;
}
case XACE_AUTH_AVAIL: {
@@ -189,14 +209,6 @@ int XaceHook(int hook, ...)
calldata = &rec;
break;
}
- case XACE_WINDOW_INIT: {
- XaceWindowRec rec = {
- va_arg(ap, ClientPtr),
- va_arg(ap, WindowPtr)
- };
- calldata = &rec;
- break;
- }
default: {
va_end(ap);
return 0; /* unimplemented hook number */
@@ -206,7 +218,7 @@ int XaceHook(int hook, ...)
/* call callbacks and return result, if any. */
CallCallbacks(&XaceHooks[hook], calldata);
- return prv ? *prv : 0;
+ return prv ? *prv : Success;
}
static int
@@ -262,16 +274,16 @@ XaceCatchDispatchProc(ClientPtr client)
{
REQUEST(xReq);
int major = stuff->reqType;
- XaceCoreDispatchRec rec = { client, TRUE /* default allow */ };
+ XaceCoreDispatchRec rec = { client, Success /* default allow */ };
if (!ProcVector[major])
- return (BadRequest);
+ return BadRequest;
/* call callbacks and return result, if any. */
CallCallbacks(&XaceHooks[XACE_CORE_DISPATCH], &rec);
- if (!rec.rval)
- return (BadAccess);
+ if (rec.status != Success)
+ return rec.status;
return client->swapped ?
(* SwappedProcVector[major])(client) :
@@ -284,12 +296,16 @@ XaceCatchExtProc(ClientPtr client)
REQUEST(xReq);
int major = stuff->reqType;
ExtensionEntry *ext = GetExtensionEntry(major);
+ XaceExtAccessRec rec = { client, ext, DixUseAccess, Success };
if (!ext || !ProcVector[major])
- return (BadRequest);
+ return BadRequest;
+
+ /* call callbacks and return result, if any. */
+ CallCallbacks(&XaceHooks[XACE_EXT_DISPATCH], &rec);
- if (!XaceHook(XACE_EXT_DISPATCH, client, ext))
- return (BadRequest); /* pretend extension doesn't exist */
+ if (rec.status != Success)
+ return BadRequest; /* pretend extension doesn't exist */
return client->swapped ?
(* SwappedProcVector[major])(client) :
diff --git a/Xext/xace.h b/Xext/xace.h
index 273635c73..de0e8fe81 100644
--- a/Xext/xace.h
+++ b/Xext/xace.h
@@ -20,15 +20,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef _XACE_H
#define _XACE_H
-/* Hook return codes */
-#define XaceErrorOperation 0
-#define XaceAllowOperation 1
-#define XaceIgnoreOperation 2
-
#ifdef XACE
#define XACE_EXTENSION_NAME "XAccessControlExtension"
-#define XACE_MAJOR_VERSION 1
+#define XACE_MAJOR_VERSION 2
#define XACE_MINOR_VERSION 0
#include "pixmap.h" /* for DrawablePtr */
@@ -45,16 +40,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define XACE_RESOURCE_ACCESS 2
#define XACE_DEVICE_ACCESS 3
#define XACE_PROPERTY_ACCESS 4
-#define XACE_DRAWABLE_ACCESS 5
-#define XACE_MAP_ACCESS 6
-#define XACE_BACKGRND_ACCESS 7
+#define XACE_SEND_ACCESS 5
+#define XACE_RECEIVE_ACCESS 6
+#define XACE_CLIENT_ACCESS 7
#define XACE_EXT_ACCESS 8
-#define XACE_HOSTLIST_ACCESS 9
-#define XACE_SITE_POLICY 10
-#define XACE_DECLARE_EXT_SECURE 11
-#define XACE_AUTH_AVAIL 12
-#define XACE_KEY_AVAIL 13
-#define XACE_WINDOW_INIT 14
+#define XACE_SERVER_ACCESS 9
+#define XACE_SELECTION_ACCESS 10
+#define XACE_SCREEN_ACCESS 11
+#define XACE_SCREENSAVER_ACCESS 12
+#define XACE_AUTH_AVAIL 13
+#define XACE_KEY_AVAIL 14
#define XACE_AUDIT_BEGIN 15
#define XACE_AUDIT_END 16
#define XACE_NUM_HOOKS 17
@@ -102,12 +97,12 @@ extern void XaceCensorImage(
/* Define calls away when XACE is not being built. */
#ifdef __GNUC__
-#define XaceHook(args...) XaceAllowOperation
+#define XaceHook(args...) Success
#define XaceHookAuditEnd(args...) { ; }
#define XaceHookAuditBegin(args...) { ; }
#define XaceCensorImage(args...) { ; }
#else
-#define XaceHook(...) XaceAllowOperation
+#define XaceHook(...) Success
#define XaceHookAuditEnd(...) { ; }
#define XaceHookAuditBegin(...) { ; }
#define XaceCensorImage(...) { ; }
diff --git a/Xext/xacestr.h b/Xext/xacestr.h
index 7114d066b..045f8364f 100644
--- a/Xext/xacestr.h
+++ b/Xext/xacestr.h
@@ -20,91 +20,110 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef _XACESTR_H
#define _XACESTR_H
-#include <X11/Xdefs.h>
#include "dixstruct.h"
#include "resource.h"
#include "extnsionst.h"
#include "gcstruct.h"
#include "windowstr.h"
#include "inputstr.h"
+#include "propertyst.h"
+#include "selection.h"
#include "xace.h"
/* XACE_CORE_DISPATCH */
typedef struct {
ClientPtr client;
- int rval;
+ int status;
} XaceCoreDispatchRec;
/* XACE_RESOURCE_ACCESS */
-/* XACE_RESOURCE_CREATE */
typedef struct {
ClientPtr client;
XID id;
RESTYPE rtype;
- Mask access_mode;
pointer res;
- int rval;
+ RESTYPE ptype;
+ pointer parent;
+ Mask access_mode;
+ int status;
} XaceResourceAccessRec;
/* XACE_DEVICE_ACCESS */
typedef struct {
ClientPtr client;
DeviceIntPtr dev;
- Bool fromRequest;
- int rval;
+ Mask access_mode;
+ int status;
} XaceDeviceAccessRec;
/* XACE_PROPERTY_ACCESS */
typedef struct {
ClientPtr client;
WindowPtr pWin;
- Atom propertyName;
+ PropertyPtr pProp;
Mask access_mode;
- int rval;
+ int status;
} XacePropertyAccessRec;
-/* XACE_DRAWABLE_ACCESS */
+/* XACE_SEND_ACCESS */
typedef struct {
ClientPtr client;
- DrawablePtr pDraw;
- int rval;
-} XaceDrawableAccessRec;
+ DeviceIntPtr dev;
+ WindowPtr pWin;
+ xEventPtr events;
+ int count;
+ int status;
+} XaceSendAccessRec;
-/* XACE_MAP_ACCESS */
-/* XACE_BACKGRND_ACCESS */
+/* XACE_RECEIVE_ACCESS */
typedef struct {
ClientPtr client;
WindowPtr pWin;
- int rval;
-} XaceMapAccessRec;
+ xEventPtr events;
+ int count;
+ int status;
+} XaceReceiveAccessRec;
+
+/* XACE_CLIENT_ACCESS */
+typedef struct {
+ ClientPtr client;
+ ClientPtr target;
+ Mask access_mode;
+ int status;
+} XaceClientAccessRec;
-/* XACE_EXT_DISPATCH_ACCESS */
+/* XACE_EXT_DISPATCH */
/* XACE_EXT_ACCESS */
typedef struct {
ClientPtr client;
ExtensionEntry *ext;
- int rval;
+ Mask access_mode;
+ int status;
} XaceExtAccessRec;
-/* XACE_HOSTLIST_ACCESS */
+/* XACE_SERVER_ACCESS */
typedef struct {
ClientPtr client;
Mask access_mode;
- int rval;
-} XaceHostlistAccessRec;
+ int status;
+} XaceServerAccessRec;
-/* XACE_SITE_POLICY */
+/* XACE_SELECTION_ACCESS */
typedef struct {
- char *policyString;
- int len;
- int rval;
-} XaceSitePolicyRec;
+ ClientPtr client;
+ Atom name;
+ Mask access_mode;
+ int status;
+} XaceSelectionAccessRec;
-/* XACE_DECLARE_EXT_SECURE */
+/* XACE_SCREEN_ACCESS */
+/* XACE_SCREENSAVER_ACCESS */
typedef struct {
- ExtensionEntry *ext;
- Bool secure;
-} XaceDeclareExtSecureRec;
+ ClientPtr client;
+ ScreenPtr screen;
+ Mask access_mode;
+ int status;
+} XaceScreenAccessRec;
/* XACE_AUTH_AVAIL */
typedef struct {
@@ -119,12 +138,6 @@ typedef struct {
int count;
} XaceKeyAvailRec;
-/* XACE_WINDOW_INIT */
-typedef struct {
- ClientPtr client;
- WindowPtr pWin;
-} XaceWindowRec;
-
/* XACE_AUDIT_BEGIN */
/* XACE_AUDIT_END */
typedef struct {
diff --git a/Xext/xcmisc.c b/Xext/xcmisc.c
index a3d40e3ce..a42d2e210 100644
--- a/Xext/xcmisc.c
+++ b/Xext/xcmisc.c
@@ -64,11 +64,9 @@ static DISPATCH_PROC(SProcXCMiscGetXIDRange);
void
XCMiscExtensionInit(INITARGS)
{
- (void) AddExtension(XCMiscExtensionName, 0, 0,
- ProcXCMiscDispatch, SProcXCMiscDispatch,
- XCMiscResetProc, StandardMinorOpcode);
-
- DeclareExtensionSecurity(XCMiscExtensionName, TRUE);
+ AddExtension(XCMiscExtensionName, 0, 0,
+ ProcXCMiscDispatch, SProcXCMiscDispatch,
+ XCMiscResetProc, StandardMinorOpcode);
}
/*ARGSUSED*/
diff --git a/Xext/xevie.c b/Xext/xevie.c
index 7922913ba..7dd67bbf6 100644
--- a/Xext/xevie.c
+++ b/Xext/xevie.c
@@ -76,11 +76,11 @@ DeviceIntPtr xeviemouse = NULL;
Mask xevieMask = 0;
int xevieEventSent = 0;
int xevieKBEventSent = 0;
-static unsigned int xevieServerGeneration;
-static int xevieDevicePrivateIndex;
+static DevPrivateKey xevieDevicePrivateKey = &xevieDevicePrivateKey;
static Bool xevieModifiersOn = FALSE;
-#define XEVIEINFO(dev) ((xevieDeviceInfoPtr)dev->devPrivates[xevieDevicePrivateIndex].ptr)
+#define XEVIEINFO(dev) ((xevieDeviceInfoPtr) \
+ dixLookupPrivate(&(dev)->devPrivates, xevieDevicePrivateKey))
Mask xevieFilters[128] =
{
@@ -134,12 +134,6 @@ XevieExtensionInit (void)
{
ExtensionEntry* extEntry;
- if (serverGeneration != xevieServerGeneration) {
- if ((xevieDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1)
- return;
- xevieServerGeneration = serverGeneration;
- }
-
if (!AddCallback(&ServerGrabCallback,XevieServerGrabStateCallback,NULL))
return;
@@ -618,14 +612,11 @@ 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;
+ dixSetPrivate(&device->devPrivates, xevieDevicePrivateKey, xeviep);
XevieUnwrapAdd(device, data);
return TRUE;
@@ -642,7 +633,7 @@ XevieRemove(DeviceIntPtr device,pointer data)
UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc);
xfree(xeviep);
- device->devPrivates[xevieDevicePrivateIndex].ptr = NULL;
+ dixSetPrivate(&device->devPrivates, xevieDevicePrivateKey, NULL);
return TRUE;
}
diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c
index f26605eb9..779f3b940 100644
--- a/Xext/xf86bigfont.c
+++ b/Xext/xf86bigfont.c
@@ -428,10 +428,10 @@ ProcXF86BigfontQueryFont(
#endif
client->errorValue = stuff->id; /* EITHER font or gc */
pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
- DixReadAccess);
+ DixGetAttrAccess);
if (!pFont) {
GC *pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC,
- DixReadAccess);
+ DixGetAttrAccess);
if (!pGC) {
client->errorValue = stuff->id;
return BadFont; /* procotol spec says only error is BadFont */
diff --git a/Xext/xprint.c b/Xext/xprint.c
index 42c6e6a2a..dba7989cc 100644
--- a/Xext/xprint.c
+++ b/Xext/xprint.c
@@ -153,8 +153,6 @@ 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);
@@ -233,21 +231,12 @@ 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);
+static DevPrivateKey XpClientPrivateKey = &XpClientPrivateKey;
+
+#define XP_GETPRIV(pClient) ((XpContextPtr) \
+ dixLookupPrivate(&(pClient)->devPrivates, XpClientPrivateKey))
+#define XP_SETPRIV(pClient, p) \
+ dixSetPrivate(&(pClient)->devPrivates, XpClientPrivateKey, p)
/*
* There are three types of resources involved. One is the resource associated
@@ -305,20 +294,6 @@ XpExtensionInit(INITARGS)
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++)
{
/*
@@ -335,7 +310,6 @@ XpExtensionInit(INITARGS)
screenInfo.screens[i]->CloseScreen = XpCloseScreen;
}
}
- DeclareExtensionSecurity(XP_PRINTNAME, TRUE);
}
static void
@@ -378,14 +352,6 @@ XpCloseScreen(int index, ScreenPtr pScreen)
}
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);
}
@@ -938,12 +904,10 @@ ProcXpCreateContext(ClientPtr client)
/*
* Allocate and add the context resource.
*/
- if((pContext = (XpContextPtr) xalloc(totalContextSize)) ==
+ if((pContext = (XpContextPtr) xalloc(sizeof(XpContextRec))) ==
(XpContextPtr) NULL)
return BadAlloc;
- InitContextPrivates(pContext);
-
if(AddResource(stuff->contextID, RTcontext, (pointer) pContext)
!= TRUE)
{
@@ -957,6 +921,7 @@ ProcXpCreateContext(ClientPtr client)
pContext->state = 0;
pContext->clientSlept = (ClientPtr)NULL;
pContext->imageRes = 0;
+ pContext->devPrivates = NULL;
pContext->funcs.DestroyContext = 0;
pContext->funcs.StartJob = 0;
@@ -1023,8 +988,7 @@ ProcXpSetContext(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xPrintSetContextReq);
- if((pContext = client->devPrivates[XpClientPrivateIndex].ptr) !=
- (pointer)NULL)
+ if((pContext = XP_GETPRIV(client)) != (pointer)NULL)
{
/*
* Erase this client's knowledge of its old context, if any.
@@ -1037,7 +1001,7 @@ ProcXpSetContext(ClientPtr client)
FreeXpClient(pPrintClient, TRUE);
}
- client->devPrivates[XpClientPrivateIndex].ptr = (pointer)NULL;
+ XP_SETPRIV(client, NULL);
}
if(stuff->printContext == None)
return Success;
@@ -1059,7 +1023,7 @@ ProcXpSetContext(ClientPtr client)
if((pPrintClient = AcquireClient(pContext, client)) == (XpClientPtr)NULL)
return BadAlloc;
- client->devPrivates[XpClientPrivateIndex].ptr = pContext;
+ XP_SETPRIV(client, pContext);
XpSetFontResFunc(client);
@@ -1072,7 +1036,7 @@ ProcXpSetContext(ClientPtr client)
XpContextPtr
XpGetPrintContext(ClientPtr client)
{
- return (client->devPrivates[XpClientPrivateIndex].ptr);
+ return XP_GETPRIV(client);
}
static int
@@ -1087,8 +1051,7 @@ ProcXpGetContext(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintGetContextReq);
- if((pContext = client->devPrivates[XpClientPrivateIndex].ptr) ==
- (pointer)NULL)
+ if((pContext = XP_GETPRIV(client)) == (pointer)NULL)
rep.printContext = None;
else
rep.printContext = pContext->contextID;
@@ -1231,6 +1194,7 @@ XpFreeContext(pointer data, XID id)
}
xfree(pContext->printerName);
+ dixFreePrivates(pContext->devPrivates);
xfree(pContext);
return Success; /* ??? */
}
@@ -1266,11 +1230,9 @@ FreeXpClient(XpClientPtr pXpClient, Bool freeResource)
* 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)
+ if(XP_GETPRIV(pXpClient->client) == pXpClient->context)
{
- pXpClient->client->devPrivates[XpClientPrivateIndex].ptr =
- (pointer)NULL;
+ XP_SETPRIV(pXpClient->client, NULL);
}
for(pPrev = (XpClientPtr)NULL, pCurrent = pContext->clientHead;
@@ -1354,87 +1316,6 @@ XpFreePage(pointer data, XID id)
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)
{
@@ -1483,8 +1364,7 @@ ProcXpStartJob(ClientPtr client)
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)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadContext;
if(pContext->state != 0)
@@ -1524,8 +1404,7 @@ ProcXpEndJob(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintEndJobReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & JOB_STARTED))
@@ -1630,8 +1509,7 @@ ProcXpStartDoc(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintStartDocReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & JOB_STARTED) ||
@@ -1666,8 +1544,7 @@ ProcXpEndDoc(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintEndDocReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & DOC_RAW_STARTED) &&
@@ -1819,8 +1696,7 @@ ProcXpStartPage(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintStartPageReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & JOB_STARTED))
@@ -1864,8 +1740,7 @@ ProcXpEndPage(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintEndPageReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & PAGE_STARTED))
@@ -1914,8 +1789,7 @@ ProcXpPutDocumentData(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xPrintPutDocumentDataReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & DOC_RAW_STARTED) &&
@@ -2425,7 +2299,7 @@ GetAllEventMasks(XpContextPtr pContext)
XpContextPtr
XpContextOfClient(ClientPtr client)
{
- return (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr;
+ return XP_GETPRIV(client);
}
diff --git a/Xext/xres.c b/Xext/xres.c
index 32cc9030d..feadad27e 100644
--- a/Xext/xres.c
+++ b/Xext/xres.c
@@ -17,6 +17,7 @@
#include "dixstruct.h"
#include "extnsionst.h"
#include "swaprep.h"
+#include "registry.h"
#include <X11/extensions/XResproto.h>
#include "pixmapstr.h"
#include "windowstr.h"
@@ -161,17 +162,20 @@ ProcXResQueryClientResources (ClientPtr client)
if(num_types) {
xXResType scratch;
+ char *name;
for(i = 0; i < lastResourceType; i++) {
if(!counts[i]) continue;
- if(!ResourceNames[i + 1]) {
+ name = (char *)LookupResourceName(i + 1);
+ if (strcmp(name, XREGISTRY_UNKNOWN))
+ scratch.resource_type = MakeAtom(name, strlen(name), TRUE);
+ else {
char buf[40];
snprintf(buf, sizeof(buf), "Unregistered resource %i", i + 1);
- RegisterResourceName(i + 1, buf);
+ scratch.resource_type = MakeAtom(buf, strlen(buf), TRUE);
}
- scratch.resource_type = ResourceNames[i + 1];
scratch.count = counts[i];
if(client->swapped) {
@@ -387,15 +391,4 @@ 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/Xext/xselinux.c b/Xext/xselinux.c
new file mode 100644
index 000000000..bbae483a8
--- /dev/null
+++ b/Xext/xselinux.c
@@ -0,0 +1,1434 @@
+/************************************************************
+
+Author: Eamon Walsh <ewalsh@epoch.ncsc.mil>
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+this permission notice appear in supporting documentation. This permission
+notice shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+********************************************************/
+
+/*
+ * Portions of this code copyright (c) 2005 by Trusted Computer Solutions, Inc.
+ * All rights reserved.
+ */
+
+#include <selinux/selinux.h>
+#include <selinux/label.h>
+#include <selinux/avc.h>
+
+#include <libaudit.h>
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xatom.h>
+#include "resource.h"
+#include "privates.h"
+#include "registry.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "scrnintstr.h"
+#include "selection.h"
+#include "xacestr.h"
+#include "xselinux.h"
+#define XSERV_t
+#define TRANS_SERVER
+#include <X11/Xtrans/Xtrans.h>
+#include "../os/osdep.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include "modinit.h"
+
+
+/*
+ * Globals
+ */
+
+/* private state record */
+static DevPrivateKey stateKey = &stateKey;
+
+/* This is what we store for security state */
+typedef struct {
+ security_id_t sid;
+ struct avc_entry_ref aeref;
+ char *command;
+} SELinuxStateRec;
+
+/* selection manager */
+typedef struct {
+ Atom selection;
+ security_id_t sid;
+} SELinuxSelectionRec;
+
+static ClientPtr selectionManager;
+static Window selectionWindow;
+
+/* audit file descriptor */
+static int audit_fd;
+
+/* structure passed to auditing callback */
+typedef struct {
+ ClientPtr client; /* client */
+ char *command; /* client's executable path */
+ unsigned id; /* resource id, if any */
+ int restype; /* resource type, if any */
+ int event; /* event type, if any */
+ Atom property; /* property name, if any */
+ Atom selection; /* selection name, if any */
+ char *extension; /* extension name, if any */
+} SELinuxAuditRec;
+
+/* labeling handle */
+static struct selabel_handle *label_hnd;
+
+/* whether AVC is active */
+static int avc_active;
+
+/* atoms for window label properties */
+static Atom atom_ctx;
+static Atom atom_client_ctx;
+
+/* The unlabeled SID */
+static security_id_t unlabeled_sid;
+
+/* Array of object classes indexed by resource type */
+static security_class_t *knownTypes;
+static unsigned numKnownTypes;
+
+/* Array of event SIDs indexed by event type */
+static security_id_t *knownEvents;
+static unsigned numKnownEvents;
+
+/* Array of selection SID structures */
+static SELinuxSelectionRec *knownSelections;
+static unsigned numKnownSelections;
+
+/* dynamically allocated security classes and permissions */
+static struct security_class_mapping map[] = {
+ { "x_drawable", { "read", "write", "destroy", "create", "getattr", "setattr", "list_property", "get_property", "set_property", "", "", "list_child", "add_child", "remove_child", "hide", "show", "blend", "override", "", "", "", "", "send", "receive", "", "manage", NULL }},
+ { "x_screen", { "", "", "", "", "getattr", "setattr", "saver_getattr", "saver_setattr", "", "", "", "", "", "", "hide_cursor", "show_cursor", "saver_hide", "saver_show", NULL }},
+ { "x_gc", { "", "", "destroy", "create", "getattr", "setattr", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "use", NULL }},
+ { "x_font", { "", "", "destroy", "create", "getattr", "", "", "", "", "", "", "", "add_glyph", "remove_glyph", "", "", "", "", "", "", "", "", "", "", "use", NULL }},
+ { "x_colormap", { "read", "write", "destroy", "create", "getattr", "", "", "", "", "", "", "", "add_color", "remove_color", "", "", "", "", "", "", "install", "uninstall", "", "", "use", NULL }},
+ { "x_property", { "read", "write", "destroy", "create", NULL }},
+ { "x_selection", { "read", "", "", "", "getattr", "setattr", NULL }},
+ { "x_cursor", { "read", "write", "destroy", "create", "getattr", "setattr", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "use", NULL }},
+ { "x_client", { "", "", "destroy", "", "getattr", "setattr", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "manage", NULL }},
+ { "x_device", { "read", "write", "", "", "getattr", "setattr", "", "", "", "getfocus", "setfocus", "", "", "", "", "", "", "grab", "freeze", "force_cursor", "", "", "", "", "", "manage", "", "bell", NULL }},
+ { "x_server", { "record", "", "", "", "getattr", "setattr", "", "", "", "", "", "", "", "", "", "", "", "grab", "", "", "", "", "", "", "", "manage", "debug", NULL }},
+ { "x_extension", { "", "", "", "", "query", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "use", NULL }},
+ { "x_event", { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "send", "receive", NULL }},
+ { "x_synthetic_event", { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "send", "receive", NULL }},
+ { "x_resource", { "read", "write", "write", "write", "read", "write", "read", "read", "write", "read", "write", "read", "write", "write", "write", "read", "read", "write", "write", "write", "write", "write", "write", "read", "read", "write", "read", "write", NULL }},
+ { NULL }
+};
+
+/* forward declarations */
+static void SELinuxScreen(CallbackListPtr *, pointer, pointer);
+
+/* "true" pointer value for use as callback data */
+static pointer truep = (pointer)1;
+
+
+/*
+ * Support Routines
+ */
+
+/*
+ * Looks up the SID corresponding to the given selection atom
+ */
+static int
+SELinuxSelectionToSID(Atom selection, SELinuxStateRec *sid_return)
+{
+ const char *name;
+ unsigned i, size;
+
+ for (i = 0; i < numKnownSelections; i++)
+ if (knownSelections[i].selection == selection) {
+ sid_return->sid = knownSelections[i].sid;
+ return Success;
+ }
+
+ /* Need to increase size of array */
+ i = numKnownSelections;
+ size = (i + 1) * sizeof(SELinuxSelectionRec);
+ knownSelections = xrealloc(knownSelections, size);
+ if (!knownSelections)
+ return BadAlloc;
+ knownSelections[i].selection = selection;
+
+ /* Look in the mappings of selection names to contexts */
+ name = NameForAtom(selection);
+ if (name) {
+ security_context_t con;
+ security_id_t sid;
+
+ if (selabel_lookup(label_hnd, &con, name, SELABEL_X_SELN) < 0) {
+ ErrorF("XSELinux: a selection label lookup failed!\n");
+ return BadValue;
+ }
+ /* Get a SID for context */
+ if (avc_context_to_sid(con, &sid) < 0) {
+ ErrorF("XSELinux: a context_to_SID call failed!\n");
+ return BadAlloc;
+ }
+ freecon(con);
+ knownSelections[i].sid = sid_return->sid = sid;
+ } else
+ knownSelections[i].sid = sid_return->sid = unlabeled_sid;
+
+ return Success;
+}
+
+/*
+ * Looks up the SID corresponding to the given event type
+ */
+static int
+SELinuxEventToSID(unsigned type, security_id_t sid_of_window,
+ SELinuxStateRec *sid_return)
+{
+ const char *name = LookupEventName(type);
+ security_context_t con;
+ type &= 127;
+
+ if (type >= numKnownEvents) {
+ /* Need to increase size of classes array */
+ unsigned size = sizeof(security_id_t);
+ knownEvents = xrealloc(knownEvents, (type + 1) * size);
+ if (!knownEvents)
+ return BadAlloc;
+ memset(knownEvents + numKnownEvents, 0,
+ (type - numKnownEvents + 1) * size);
+ numKnownEvents = type + 1;
+ }
+
+ if (!knownEvents[type]) {
+ /* Look in the mappings of event names to contexts */
+ if (selabel_lookup(label_hnd, &con, name, SELABEL_X_EVENT) < 0) {
+ ErrorF("XSELinux: an event label lookup failed!\n");
+ return BadValue;
+ }
+ /* Get a SID for context */
+ if (avc_context_to_sid(con, knownEvents + type) < 0) {
+ ErrorF("XSELinux: a context_to_SID call failed!\n");
+ return BadAlloc;
+ }
+ freecon(con);
+ }
+
+ /* Perform a transition to obtain the final SID */
+ if (avc_compute_create(sid_of_window, knownEvents[type], SECCLASS_X_EVENT,
+ &sid_return->sid) < 0) {
+ ErrorF("XSELinux: a compute_create call failed!\n");
+ return BadValue;
+ }
+
+ return Success;
+}
+
+/*
+ * Returns the object class corresponding to the given resource type.
+ */
+static security_class_t
+SELinuxTypeToClass(RESTYPE type)
+{
+ RESTYPE fulltype = type;
+ type &= TypeMask;
+
+ if (type >= numKnownTypes) {
+ /* Need to increase size of classes array */
+ unsigned size = sizeof(security_class_t);
+ knownTypes = xrealloc(knownTypes, (type + 1) * size);
+ if (!knownTypes)
+ return 0;
+ memset(knownTypes + numKnownTypes, 0,
+ (type - numKnownTypes + 1) * size);
+ numKnownTypes = type + 1;
+ }
+
+ if (!knownTypes[type]) {
+ const char *str;
+ knownTypes[type] = SECCLASS_X_RESOURCE;
+
+ if (fulltype & RC_DRAWABLE)
+ knownTypes[type] = SECCLASS_X_DRAWABLE;
+ if (fulltype == RT_GC)
+ knownTypes[type] = SECCLASS_X_GC;
+ if (fulltype == RT_FONT)
+ knownTypes[type] = SECCLASS_X_FONT;
+ if (fulltype == RT_CURSOR)
+ knownTypes[type] = SECCLASS_X_CURSOR;
+ if (fulltype == RT_COLORMAP)
+ knownTypes[type] = SECCLASS_X_COLORMAP;
+
+ /* Need to do a string lookup */
+ str = LookupResourceName(fulltype);
+ if (!strcmp(str, "PICTURE"))
+ knownTypes[type] = SECCLASS_X_DRAWABLE;
+ if (!strcmp(str, "GLYPHSET"))
+ knownTypes[type] = SECCLASS_X_FONT;
+ }
+
+ return knownTypes[type];
+}
+
+/*
+ * Performs an SELinux permission check.
+ */
+static int
+SELinuxDoCheck(int clientIndex, SELinuxStateRec *subj, SELinuxStateRec *obj,
+ security_class_t class, Mask mode, SELinuxAuditRec *auditdata)
+{
+ /* serverClient requests OK */
+ if (clientIndex == 0)
+ return Success;
+
+ auditdata->command = subj->command;
+ errno = 0;
+
+ if (avc_has_perm(subj->sid, obj->sid, class, mode, &subj->aeref,
+ auditdata) < 0) {
+ if (errno == EACCES)
+ return BadAccess;
+ ErrorF("ServerPerm: unexpected error %d\n", errno);
+ return BadValue;
+ }
+
+ return Success;
+}
+
+/*
+ * Labels a newly connected client.
+ */
+static void
+SELinuxLabelClient(ClientPtr client)
+{
+ XtransConnInfo ci = ((OsCommPtr)client->osPrivate)->trans_conn;
+ SELinuxStateRec *state;
+ security_context_t ctx;
+
+ state = dixLookupPrivate(&client->devPrivates, stateKey);
+ sidput(state->sid);
+
+ if (_XSERVTransIsLocal(ci)) {
+ int fd = _XSERVTransGetConnectionNumber(ci);
+ struct ucred creds;
+ socklen_t len = sizeof(creds);
+ char path[PATH_MAX + 1];
+ size_t bytes;
+
+ /* For local clients, can get context from the socket */
+ if (getpeercon(fd, &ctx) < 0)
+ FatalError("Client %d: couldn't get context from socket\n",
+ client->index);
+
+ /* Try and determine the client's executable name */
+ memset(&creds, 0, sizeof(creds));
+ if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &creds, &len) < 0)
+ goto finish;
+
+ snprintf(path, PATH_MAX + 1, "/proc/%d/cmdline", creds.pid);
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ goto finish;
+
+ bytes = read(fd, path, PATH_MAX + 1);
+ close(fd);
+ if (bytes <= 0)
+ goto finish;
+
+ state->command = xalloc(bytes);
+ if (!state->command)
+ goto finish;
+
+ memcpy(state->command, path, bytes);
+ state->command[bytes - 1] = 0;
+ } else
+ /* For remote clients, need to use a default context */
+ if (selabel_lookup(label_hnd, &ctx, NULL, SELABEL_X_CLIENT) < 0)
+ FatalError("Client %d: couldn't get default remote context\n",
+ client->index);
+
+finish:
+ /* Get a SID from the context */
+ if (avc_context_to_sid(ctx, &state->sid) < 0)
+ FatalError("Client %d: context_to_sid(%s) failed\n",
+ client->index, ctx);
+
+ freecon(ctx);
+}
+
+/*
+ * Labels initial server objects.
+ */
+static void
+SELinuxLabelInitial(void)
+{
+ int i;
+ XaceScreenAccessRec srec;
+ SELinuxStateRec *state;
+ security_context_t ctx;
+ pointer unused;
+
+ /* Do the serverClient */
+ state = dixLookupPrivate(&serverClient->devPrivates, stateKey);
+ sidput(state->sid);
+
+ /* Use the context of the X server process for the serverClient */
+ if (getcon(&ctx) < 0)
+ FatalError("Couldn't get context of X server process\n");
+
+ /* Get a SID from the context */
+ if (avc_context_to_sid(ctx, &state->sid) < 0)
+ FatalError("serverClient: context_to_sid(%s) failed\n", ctx);
+
+ freecon(ctx);
+
+ srec.client = serverClient;
+ srec.access_mode = DixCreateAccess;
+ srec.status = Success;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ /* Do the screen object */
+ srec.screen = screenInfo.screens[i];
+ SELinuxScreen(NULL, NULL, &srec);
+
+ /* Do the default colormap */
+ dixLookupResource(&unused, screenInfo.screens[i]->defColormap,
+ RT_COLORMAP, serverClient, DixCreateAccess);
+ }
+}
+
+
+/*
+ * Libselinux Callbacks
+ */
+
+static int
+SELinuxAudit(void *auditdata,
+ security_class_t class,
+ char *msgbuf,
+ size_t msgbufsize)
+{
+ SELinuxAuditRec *audit = auditdata;
+ ClientPtr client = audit->client;
+ char idNum[16], *propertyName, *selectionName;
+ int major = -1, minor = -1;
+
+ if (client) {
+ REQUEST(xReq);
+ if (stuff) {
+ major = stuff->reqType;
+ minor = MinorOpcodeOfRequest(client);
+ }
+ }
+ if (audit->id)
+ snprintf(idNum, 16, "%x", audit->id);
+
+ propertyName = audit->property ? NameForAtom(audit->property) : NULL;
+ selectionName = audit->selection ? NameForAtom(audit->selection) : NULL;
+
+ return snprintf(msgbuf, msgbufsize, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ (major >= 0) ? "request=" : "",
+ (major >= 0) ? LookupRequestName(major, minor) : "",
+ audit->command ? " comm=" : "",
+ audit->command ? audit->command : "",
+ audit->id ? " resid=" : "",
+ audit->id ? idNum : "",
+ audit->restype ? " restype=" : "",
+ audit->restype ? LookupResourceName(audit->restype) : "",
+ audit->event ? " event=" : "",
+ audit->event ? LookupEventName(audit->event & 127) : "",
+ audit->property ? " property=" : "",
+ audit->property ? propertyName : "",
+ audit->selection ? " selection=" : "",
+ audit->selection ? selectionName : "",
+ audit->extension ? " extension=" : "",
+ audit->extension ? audit->extension : "");
+}
+
+static int
+SELinuxLog(int type, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ VErrorF(fmt, ap);
+ va_end(ap);
+ return 0;
+}
+
+/*
+ * XACE Callbacks
+ */
+
+static void
+SELinuxDevice(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceDeviceAccessRec *rec = calldata;
+ SELinuxStateRec *subj, *obj;
+ SELinuxAuditRec auditdata = { .client = rec->client };
+ int rc;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&rec->dev->devPrivates, stateKey);
+
+ /* If this is a new object that needs labeling, do it now */
+ if (rec->access_mode & DixCreateAccess) {
+ sidput(obj->sid);
+
+ /* Label the device directly with the process SID */
+ sidget(subj->sid);
+ obj->sid = subj->sid;
+ }
+
+ rc = SELinuxDoCheck(rec->client->index, subj, obj, SECCLASS_X_DEVICE,
+ rec->access_mode, &auditdata);
+ if (rc != Success)
+ rec->status = rc;
+}
+
+static void
+SELinuxSend(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceSendAccessRec *rec = calldata;
+ SELinuxStateRec *subj, *obj, ev_sid;
+ SELinuxAuditRec auditdata = { .client = rec->client };
+ security_class_t class;
+ int rc, i, type, clientIndex;
+
+ if (rec->dev) {
+ subj = dixLookupPrivate(&rec->dev->devPrivates, stateKey);
+ clientIndex = -1; /* some nonzero value */
+ } else {
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ clientIndex = rec->client->index;
+ }
+
+ obj = dixLookupPrivate(&rec->pWin->devPrivates, stateKey);
+
+ /* Check send permission on window */
+ rc = SELinuxDoCheck(clientIndex, subj, obj, SECCLASS_X_DRAWABLE,
+ DixSendAccess, &auditdata);
+ if (rc != Success)
+ goto err;
+
+ /* Check send permission on specific event types */
+ for (i = 0; i < rec->count; i++) {
+ type = rec->events[i].u.u.type;
+ class = (type & 128) ? SECCLASS_X_FAKEEVENT : SECCLASS_X_EVENT;
+
+ rc = SELinuxEventToSID(type, obj->sid, &ev_sid);
+ if (rc != Success)
+ goto err;
+
+ auditdata.event = type;
+ rc = SELinuxDoCheck(clientIndex, subj, &ev_sid, class,
+ DixSendAccess, &auditdata);
+ if (rc != Success)
+ goto err;
+ }
+ return;
+err:
+ rec->status = rc;
+}
+
+static void
+SELinuxReceive(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceReceiveAccessRec *rec = calldata;
+ SELinuxStateRec *subj, *obj, ev_sid;
+ SELinuxAuditRec auditdata = { .client = NULL };
+ security_class_t class;
+ int rc, i, type;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&rec->pWin->devPrivates, stateKey);
+
+ /* Check receive permission on window */
+ rc = SELinuxDoCheck(rec->client->index, subj, obj, SECCLASS_X_DRAWABLE,
+ DixReceiveAccess, &auditdata);
+ if (rc != Success)
+ goto err;
+
+ /* Check receive permission on specific event types */
+ for (i = 0; i < rec->count; i++) {
+ type = rec->events[i].u.u.type;
+ class = (type & 128) ? SECCLASS_X_FAKEEVENT : SECCLASS_X_EVENT;
+
+ rc = SELinuxEventToSID(type, obj->sid, &ev_sid);
+ if (rc != Success)
+ goto err;
+
+ auditdata.event = type;
+ rc = SELinuxDoCheck(rec->client->index, subj, &ev_sid, class,
+ DixReceiveAccess, &auditdata);
+ if (rc != Success)
+ goto err;
+ }
+ return;
+err:
+ rec->status = rc;
+}
+
+static void
+SELinuxExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceExtAccessRec *rec = calldata;
+ SELinuxStateRec *subj, *obj, *serv;
+ SELinuxAuditRec auditdata = { .client = rec->client };
+ int rc;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&rec->ext->devPrivates, stateKey);
+
+ /* If this is a new object that needs labeling, do it now */
+ /* XXX there should be a separate callback for this */
+ if (obj->sid == unlabeled_sid) {
+ const char *name = rec->ext->name;
+ security_context_t con;
+ security_id_t sid;
+
+ serv = dixLookupPrivate(&serverClient->devPrivates, stateKey);
+
+ /* Look in the mappings of property names to contexts */
+ if (selabel_lookup(label_hnd, &con, name, SELABEL_X_EXT) < 0) {
+ ErrorF("XSELinux: a property label lookup failed!\n");
+ rec->status = BadValue;
+ return;
+ }
+ /* Get a SID for context */
+ if (avc_context_to_sid(con, &sid) < 0) {
+ ErrorF("XSELinux: a context_to_SID call failed!\n");
+ rec->status = BadAlloc;
+ return;
+ }
+
+ sidput(obj->sid);
+
+ /* Perform a transition to obtain the final SID */
+ if (avc_compute_create(serv->sid, sid, SECCLASS_X_EXTENSION,
+ &obj->sid) < 0) {
+ ErrorF("XSELinux: a SID transition call failed!\n");
+ freecon(con);
+ rec->status = BadValue;
+ return;
+ }
+ freecon(con);
+ }
+
+ /* Perform the security check */
+ auditdata.extension = rec->ext->name;
+ rc = SELinuxDoCheck(rec->client->index, subj, obj, SECCLASS_X_EXTENSION,
+ rec->access_mode, &auditdata);
+ if (rc != Success)
+ rec->status = rc;
+}
+
+static void
+SELinuxProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XacePropertyAccessRec *rec = calldata;
+ SELinuxStateRec *subj, *obj;
+ SELinuxAuditRec auditdata = { .client = rec->client };
+ int rc;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&rec->pProp->devPrivates, stateKey);
+
+ /* If this is a new object that needs labeling, do it now */
+ if (rec->access_mode & DixCreateAccess) {
+ const char *name = NameForAtom(rec->pProp->propertyName);
+ security_context_t con;
+ security_id_t sid;
+
+ /* Look in the mappings of property names to contexts */
+ if (selabel_lookup(label_hnd, &con, name, SELABEL_X_PROP) < 0) {
+ ErrorF("XSELinux: a property label lookup failed!\n");
+ rec->status = BadValue;
+ return;
+ }
+ /* Get a SID for context */
+ if (avc_context_to_sid(con, &sid) < 0) {
+ ErrorF("XSELinux: a context_to_SID call failed!\n");
+ rec->status = BadAlloc;
+ return;
+ }
+
+ sidput(obj->sid);
+
+ /* Perform a transition to obtain the final SID */
+ if (avc_compute_create(subj->sid, sid, SECCLASS_X_PROPERTY,
+ &obj->sid) < 0) {
+ ErrorF("XSELinux: a SID transition call failed!\n");
+ freecon(con);
+ rec->status = BadValue;
+ return;
+ }
+ freecon(con);
+ avc_entry_ref_init(&obj->aeref);
+ }
+
+ /* Perform the security check */
+ auditdata.property = rec->pProp->propertyName;
+ rc = SELinuxDoCheck(rec->client->index, subj, obj, SECCLASS_X_PROPERTY,
+ rec->access_mode, &auditdata);
+ if (rc != Success)
+ rec->status = rc;
+}
+
+static void
+SELinuxResource(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceResourceAccessRec *rec = calldata;
+ SELinuxStateRec *subj, *obj, *pobj;
+ SELinuxAuditRec auditdata = { .client = rec->client };
+ PrivateRec **privatePtr;
+ security_class_t class;
+ int rc, offset;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+
+ /* Determine if the resource object has a devPrivates field */
+ offset = dixLookupPrivateOffset(rec->rtype);
+ if (offset < 0) {
+ /* No: use the SID of the owning client */
+ class = SECCLASS_X_RESOURCE;
+ privatePtr = &clients[CLIENT_ID(rec->id)]->devPrivates;
+ obj = dixLookupPrivate(privatePtr, stateKey);
+ } else {
+ /* Yes: use the SID from the resource object itself */
+ class = SELinuxTypeToClass(rec->rtype);
+ privatePtr = DEVPRIV_AT(rec->res, offset);
+ obj = dixLookupPrivate(privatePtr, stateKey);
+ }
+
+ /* If this is a new object that needs labeling, do it now */
+ if (rec->access_mode & DixCreateAccess && offset >= 0) {
+ if (rec->parent)
+ offset = dixLookupPrivateOffset(rec->ptype);
+ if (rec->parent && offset >= 0)
+ /* Use the SID of the parent object in the labeling operation */
+ pobj = dixLookupPrivate(DEVPRIV_AT(rec->parent, offset), stateKey);
+ else
+ /* Use the SID of the subject */
+ pobj = subj;
+
+ sidput(obj->sid);
+
+ /* Perform a transition to obtain the final SID */
+ if (avc_compute_create(subj->sid, pobj->sid, class, &obj->sid) < 0) {
+ ErrorF("XSELinux: a compute_create call failed!\n");
+ rec->status = BadValue;
+ return;
+ }
+ }
+
+ /* Perform the security check */
+ auditdata.restype = rec->rtype;
+ auditdata.id = rec->id;
+ rc = SELinuxDoCheck(rec->client->index, subj, obj, class,
+ rec->access_mode, &auditdata);
+ if (rc != Success)
+ rec->status = rc;
+}
+
+static void
+SELinuxScreen(CallbackListPtr *pcbl, pointer is_saver, pointer calldata)
+{
+ XaceScreenAccessRec *rec = calldata;
+ SELinuxStateRec *subj, *obj;
+ SELinuxAuditRec auditdata = { .client = rec->client };
+ Mask access_mode = rec->access_mode;
+ int rc;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&rec->screen->devPrivates, stateKey);
+
+ /* If this is a new object that needs labeling, do it now */
+ if (access_mode & DixCreateAccess) {
+ sidput(obj->sid);
+
+ /* Perform a transition to obtain the final SID */
+ if (avc_compute_create(subj->sid, subj->sid, SECCLASS_X_SCREEN,
+ &obj->sid) < 0) {
+ ErrorF("XSELinux: a compute_create call failed!\n");
+ rec->status = BadValue;
+ return;
+ }
+ }
+
+ if (is_saver)
+ access_mode <<= 2;
+
+ rc = SELinuxDoCheck(rec->client->index, subj, obj, SECCLASS_X_SCREEN,
+ access_mode, &auditdata);
+ if (rc != Success)
+ rec->status = rc;
+}
+
+static void
+SELinuxClient(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceClientAccessRec *rec = calldata;
+ SELinuxStateRec *subj, *obj;
+ SELinuxAuditRec auditdata = { .client = rec->client };
+ int rc;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&rec->target->devPrivates, stateKey);
+
+ rc = SELinuxDoCheck(rec->client->index, subj, obj, SECCLASS_X_CLIENT,
+ rec->access_mode, &auditdata);
+ if (rc != Success)
+ rec->status = rc;
+}
+
+static void
+SELinuxServer(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceServerAccessRec *rec = calldata;
+ SELinuxStateRec *subj, *obj;
+ SELinuxAuditRec auditdata = { .client = rec->client };
+ int rc;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&serverClient->devPrivates, stateKey);
+
+ rc = SELinuxDoCheck(rec->client->index, subj, obj, SECCLASS_X_SERVER,
+ rec->access_mode, &auditdata);
+ if (rc != Success)
+ rec->status = rc;
+}
+
+static void
+SELinuxSelection(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ XaceSelectionAccessRec *rec = (XaceSelectionAccessRec *)calldata;
+ SELinuxStateRec *subj, sel_sid;
+ SELinuxAuditRec auditdata = { .client = rec->client };
+ int rc;
+
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+
+ rc = SELinuxSelectionToSID(rec->name, &sel_sid);
+ if (rc != Success) {
+ rec->status = rc;
+ return;
+ }
+
+ auditdata.selection = rec->name;
+ rc = SELinuxDoCheck(rec->client->index, subj, &sel_sid,
+ SECCLASS_X_SELECTION, rec->access_mode, &auditdata);
+ if (rc != Success)
+ rec->status = rc;
+}
+
+
+/*
+ * DIX Callbacks
+ */
+
+static void
+SELinuxClientState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ NewClientInfoRec *pci = calldata;
+
+ switch (pci->client->clientState) {
+ case ClientStateInitial:
+ SELinuxLabelClient(pci->client);
+ break;
+
+ case ClientStateRetained:
+ case ClientStateGone:
+ if (pci->client == selectionManager) {
+ selectionManager = NULL;
+ selectionWindow = 0;
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void
+SELinuxResourceState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ ResourceStateInfoRec *rec = calldata;
+ SELinuxStateRec *state;
+ WindowPtr pWin;
+
+ if (rec->type != RT_WINDOW)
+ return;
+
+ pWin = (WindowPtr)rec->value;
+ state = dixLookupPrivate(&wClient(pWin)->devPrivates, stateKey);
+
+ if (state->sid) {
+ security_context_t ctx;
+ int rc = avc_sid_to_context(state->sid, &ctx);
+ if (rc < 0)
+ FatalError("XSELinux: Failed to get security context!\n");
+ rc = dixChangeWindowProperty(serverClient,
+ pWin, atom_client_ctx, XA_STRING, 8,
+ PropModeReplace, strlen(ctx), ctx, FALSE);
+ if (rc != Success)
+ FatalError("XSELinux: Failed to set label property on window!\n");
+ freecon(ctx);
+ }
+ else
+ FatalError("XSELinux: Unexpected unlabeled client found\n");
+
+ state = dixLookupPrivate(&pWin->devPrivates, stateKey);
+
+ if (state->sid) {
+ security_context_t ctx;
+ int rc = avc_sid_to_context(state->sid, &ctx);
+ if (rc < 0)
+ FatalError("XSELinux: Failed to get security context!\n");
+ rc = dixChangeWindowProperty(serverClient,
+ pWin, atom_ctx, XA_STRING, 8,
+ PropModeReplace, strlen(ctx), ctx, FALSE);
+ if (rc != Success)
+ FatalError("XSELinux: Failed to set label property on window!\n");
+ freecon(ctx);
+ }
+ else
+ FatalError("XSELinux: Unexpected unlabeled window found\n");
+}
+
+static void
+SELinuxSelectionState(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ SelectionInfoRec *rec = calldata;
+ SELinuxStateRec *subj, *obj;
+
+ switch (rec->kind) {
+ case SelectionSetOwner:
+ /* save off the "real" owner of the selection */
+ rec->selection->alt_client = rec->selection->client;
+ rec->selection->alt_window = rec->selection->window;
+
+ /* figure out the new label for the content */
+ subj = dixLookupPrivate(&rec->client->devPrivates, stateKey);
+ obj = dixLookupPrivate(&rec->selection->devPrivates, stateKey);
+ sidput(obj->sid);
+
+ if (avc_compute_create(subj->sid, subj->sid, SECCLASS_X_SELECTION,
+ &obj->sid) < 0) {
+ ErrorF("XSELinux: a compute_create call failed!\n");
+ obj->sid = unlabeled_sid;
+ }
+ break;
+
+ case SelectionGetOwner:
+ /* restore the real owner */
+ rec->selection->window = rec->selection->alt_window;
+ break;
+
+ case SelectionConvertSelection:
+ /* redirect the convert request if necessary */
+ if (selectionManager && selectionManager != rec->client) {
+ rec->selection->client = selectionManager;
+ rec->selection->window = selectionWindow;
+ } else {
+ rec->selection->client = rec->selection->alt_client;
+ rec->selection->window = rec->selection->alt_window;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+
+/*
+ * DevPrivates Callbacks
+ */
+
+static void
+SELinuxStateInit(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ PrivateCallbackRec *rec = calldata;
+ SELinuxStateRec *state = *rec->value;
+
+ sidget(unlabeled_sid);
+ state->sid = unlabeled_sid;
+
+ avc_entry_ref_init(&state->aeref);
+}
+
+static void
+SELinuxStateFree(CallbackListPtr *pcbl, pointer unused, pointer calldata)
+{
+ PrivateCallbackRec *rec = calldata;
+ SELinuxStateRec *state = *rec->value;
+
+ xfree(state->command);
+
+ if (avc_active)
+ sidput(state->sid);
+}
+
+
+/*
+ * Extension Dispatch
+ */
+
+static int
+ProcSELinuxQueryVersion(ClientPtr client)
+{
+ SELinuxQueryVersionReply rep;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.server_major = XSELINUX_MAJOR_VERSION;
+ rep.server_minor = XSELINUX_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(rep), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcSELinuxSetSelectionManager(ClientPtr client)
+{
+ WindowPtr pWin;
+ int rc;
+
+ REQUEST(SELinuxSetSelectionManagerReq);
+ REQUEST_SIZE_MATCH(SELinuxSetSelectionManagerReq);
+
+ if (stuff->window == None) {
+ selectionManager = NULL;
+ selectionWindow = None;
+ } else {
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW,
+ client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
+ selectionManager = client;
+ selectionWindow = stuff->window;
+ }
+
+ return Success;
+}
+
+static int
+ProcSELinuxGetSelectionManager(ClientPtr client)
+{
+ SELinuxGetSelectionManagerReply rep;
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.window = selectionWindow;
+ if (client->swapped) {
+ int n;
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swapl(&rep.window, n);
+ }
+ WriteToClient(client, sizeof(rep), (char *)&rep);
+ return (client->noClientException);
+}
+
+static int
+ProcSELinuxSetDeviceCreateContext(ClientPtr client)
+{
+ return Success;
+}
+
+static int
+ProcSELinuxGetDeviceCreateContext(ClientPtr client)
+{
+ return Success;
+}
+
+static int
+ProcSELinuxSetDeviceContext(ClientPtr client)
+{
+ char *ctx;
+ security_id_t sid;
+ DeviceIntPtr dev;
+ SELinuxStateRec *state;
+ int rc;
+
+ REQUEST(SELinuxSetContextReq);
+ REQUEST_FIXED_SIZE(SELinuxSetContextReq, stuff->context_len);
+
+ ctx = (char *)(stuff + 1);
+ if (ctx[stuff->context_len - 1])
+ return BadLength;
+
+ rc = dixLookupDevice(&dev, stuff->id, client, DixManageAccess);
+ if (rc != Success)
+ return rc;
+
+ rc = avc_context_to_sid(ctx, &sid);
+ if (rc != Success)
+ return BadValue;
+
+ state = dixLookupPrivate(&dev->devPrivates, stateKey);
+ sidput(state->sid);
+ state->sid = sid;
+ return Success;
+}
+
+static int
+ProcSELinuxGetDeviceContext(ClientPtr client)
+{
+ return Success;
+}
+
+static int
+ProcSELinuxSetPropertyCreateContext(ClientPtr client)
+{
+ return Success;
+}
+
+static int
+ProcSELinuxGetPropertyCreateContext(ClientPtr client)
+{
+ return Success;
+}
+
+static int
+ProcSELinuxGetPropertyContext(ClientPtr client)
+{
+ return Success;
+}
+
+static int
+ProcSELinuxSetWindowCreateContext(ClientPtr client)
+{
+ return Success;
+}
+
+static int
+ProcSELinuxGetWindowCreateContext(ClientPtr client)
+{
+ return Success;
+}
+
+static int
+ProcSELinuxGetWindowContext(ClientPtr client)
+{
+ return Success;
+}
+
+static int
+ProcSELinuxDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ switch (stuff->data) {
+ case X_SELinuxQueryVersion:
+ return ProcSELinuxQueryVersion(client);
+ case X_SELinuxSetSelectionManager:
+ return ProcSELinuxSetSelectionManager(client);
+ case X_SELinuxGetSelectionManager:
+ return ProcSELinuxGetSelectionManager(client);
+ case X_SELinuxSetDeviceCreateContext:
+ return ProcSELinuxSetDeviceCreateContext(client);
+ case X_SELinuxGetDeviceCreateContext:
+ return ProcSELinuxGetDeviceCreateContext(client);
+ case X_SELinuxSetDeviceContext:
+ return ProcSELinuxSetDeviceContext(client);
+ case X_SELinuxGetDeviceContext:
+ return ProcSELinuxGetDeviceContext(client);
+ case X_SELinuxSetPropertyCreateContext:
+ return ProcSELinuxSetPropertyCreateContext(client);
+ case X_SELinuxGetPropertyCreateContext:
+ return ProcSELinuxGetPropertyCreateContext(client);
+ case X_SELinuxGetPropertyContext:
+ return ProcSELinuxGetPropertyContext(client);
+ case X_SELinuxSetWindowCreateContext:
+ return ProcSELinuxSetWindowCreateContext(client);
+ case X_SELinuxGetWindowCreateContext:
+ return ProcSELinuxGetWindowCreateContext(client);
+ case X_SELinuxGetWindowContext:
+ return ProcSELinuxGetWindowContext(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcSELinuxQueryVersion(ClientPtr client)
+{
+ REQUEST(SELinuxQueryVersionReq);
+ int n;
+
+ REQUEST_SIZE_MATCH (SELinuxQueryVersionReq);
+ swaps(&stuff->client_major,n);
+ swaps(&stuff->client_minor,n);
+ return ProcSELinuxQueryVersion(client);
+}
+
+static int
+SProcSELinuxSetSelectionManager(ClientPtr client)
+{
+ REQUEST(SELinuxSetSelectionManagerReq);
+ int n;
+
+ REQUEST_SIZE_MATCH (SELinuxSetSelectionManagerReq);
+ swapl(&stuff->window,n);
+ return ProcSELinuxSetSelectionManager(client);
+}
+
+static int
+SProcSELinuxGetSelectionManager(ClientPtr client)
+{
+ return ProcSELinuxGetSelectionManager(client);
+}
+
+static int
+SProcSELinuxSetDeviceCreateContext(ClientPtr client)
+{
+ return ProcSELinuxSetDeviceCreateContext(client);
+}
+
+static int
+SProcSELinuxGetDeviceCreateContext(ClientPtr client)
+{
+ return ProcSELinuxGetDeviceCreateContext(client);
+}
+
+static int
+SProcSELinuxSetDeviceContext(ClientPtr client)
+{
+ return ProcSELinuxSetDeviceContext(client);
+}
+
+static int
+SProcSELinuxGetDeviceContext(ClientPtr client)
+{
+ return ProcSELinuxGetDeviceContext(client);
+}
+
+static int
+SProcSELinuxSetPropertyCreateContext(ClientPtr client)
+{
+ return ProcSELinuxSetPropertyCreateContext(client);
+}
+
+static int
+SProcSELinuxGetPropertyCreateContext(ClientPtr client)
+{
+ return ProcSELinuxGetPropertyCreateContext(client);
+}
+
+static int
+SProcSELinuxGetPropertyContext(ClientPtr client)
+{
+ return ProcSELinuxGetPropertyContext(client);
+}
+
+static int
+SProcSELinuxSetWindowCreateContext(ClientPtr client)
+{
+ return ProcSELinuxSetWindowCreateContext(client);
+}
+
+static int
+SProcSELinuxGetWindowCreateContext(ClientPtr client)
+{
+ return ProcSELinuxGetWindowCreateContext(client);
+}
+
+static int
+SProcSELinuxGetWindowContext(ClientPtr client)
+{
+ return ProcSELinuxGetWindowContext(client);
+}
+
+static int
+SProcSELinuxDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ int n;
+
+ swaps(&stuff->length, n);
+
+ switch (stuff->data) {
+ case X_SELinuxQueryVersion:
+ return SProcSELinuxQueryVersion(client);
+ case X_SELinuxSetSelectionManager:
+ return SProcSELinuxSetSelectionManager(client);
+ case X_SELinuxGetSelectionManager:
+ return SProcSELinuxGetSelectionManager(client);
+ case X_SELinuxSetDeviceCreateContext:
+ return SProcSELinuxSetDeviceCreateContext(client);
+ case X_SELinuxGetDeviceCreateContext:
+ return SProcSELinuxGetDeviceCreateContext(client);
+ case X_SELinuxSetDeviceContext:
+ return SProcSELinuxSetDeviceContext(client);
+ case X_SELinuxGetDeviceContext:
+ return SProcSELinuxGetDeviceContext(client);
+ case X_SELinuxSetPropertyCreateContext:
+ return SProcSELinuxSetPropertyCreateContext(client);
+ case X_SELinuxGetPropertyCreateContext:
+ return SProcSELinuxGetPropertyCreateContext(client);
+ case X_SELinuxGetPropertyContext:
+ return SProcSELinuxGetPropertyContext(client);
+ case X_SELinuxSetWindowCreateContext:
+ return SProcSELinuxSetWindowCreateContext(client);
+ case X_SELinuxGetWindowCreateContext:
+ return SProcSELinuxGetWindowCreateContext(client);
+ case X_SELinuxGetWindowContext:
+ return SProcSELinuxGetWindowContext(client);
+ default:
+ return BadRequest;
+ }
+}
+
+
+/*
+ * Extension Setup / Teardown
+ */
+
+static void
+SELinuxResetProc(ExtensionEntry *extEntry)
+{
+ /* Unregister callbacks */
+ DeleteCallback(&ClientStateCallback, SELinuxClientState, NULL);
+ DeleteCallback(&ResourceStateCallback, SELinuxResourceState, NULL);
+ DeleteCallback(&SelectionCallback, SELinuxSelectionState, NULL);
+
+ XaceDeleteCallback(XACE_EXT_DISPATCH, SELinuxExtension, NULL);
+ XaceDeleteCallback(XACE_RESOURCE_ACCESS, SELinuxResource, NULL);
+ XaceDeleteCallback(XACE_DEVICE_ACCESS, SELinuxDevice, NULL);
+ XaceDeleteCallback(XACE_PROPERTY_ACCESS, SELinuxProperty, NULL);
+ XaceDeleteCallback(XACE_SEND_ACCESS, SELinuxSend, NULL);
+ XaceDeleteCallback(XACE_RECEIVE_ACCESS, SELinuxReceive, NULL);
+ XaceDeleteCallback(XACE_CLIENT_ACCESS, SELinuxClient, NULL);
+ XaceDeleteCallback(XACE_EXT_ACCESS, SELinuxExtension, NULL);
+ XaceDeleteCallback(XACE_SERVER_ACCESS, SELinuxServer, NULL);
+ XaceDeleteCallback(XACE_SELECTION_ACCESS, SELinuxSelection, NULL);
+ XaceDeleteCallback(XACE_SCREEN_ACCESS, SELinuxScreen, NULL);
+ XaceDeleteCallback(XACE_SCREENSAVER_ACCESS, SELinuxScreen, truep);
+
+ /* Tear down SELinux stuff */
+ selabel_close(label_hnd);
+ label_hnd = NULL;
+
+ audit_close(audit_fd);
+
+ avc_destroy();
+ avc_active = 0;
+
+ /* Free local state */
+ xfree(knownSelections);
+ knownSelections = NULL;
+ numKnownSelections = 0;
+
+ xfree(knownEvents);
+ knownEvents = NULL;
+ numKnownEvents = 0;
+
+ xfree(knownTypes);
+ knownTypes = NULL;
+ numKnownTypes = 0;
+}
+
+void
+XSELinuxExtensionInit(INITARGS)
+{
+ ExtensionEntry *extEntry;
+ struct selinux_opt options[] = { { SELABEL_OPT_VALIDATE, (char *)1 } };
+ security_context_t con;
+ int ret = TRUE;
+
+ /* Setup SELinux stuff */
+ if (!is_selinux_enabled()) {
+ ErrorF("XSELinux: Extension failed to load: SELinux not enabled\n");
+ return;
+ }
+
+ selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback)SELinuxLog);
+ selinux_set_callback(SELINUX_CB_AUDIT, (union selinux_callback)SELinuxAudit);
+
+ if (selinux_set_mapping(map) < 0)
+ FatalError("XSELinux: Failed to set up security class mapping\n");
+
+ if (avc_open(NULL, 0) < 0)
+ FatalError("XSELinux: Couldn't initialize SELinux userspace AVC\n");
+ avc_active = 1;
+
+ label_hnd = selabel_open(SELABEL_CTX_X, options, 1);
+ if (!label_hnd)
+ FatalError("XSELinux: Failed to open x_contexts mapping in policy\n");
+
+ if (security_get_initial_context("unlabeled", &con) < 0)
+ FatalError("XSELinux: Failed to look up unlabeled context\n");
+ if (avc_context_to_sid(con, &unlabeled_sid) < 0)
+ FatalError("XSELinux: a context_to_SID call failed!\n");
+ freecon(con);
+
+ /* Prepare for auditing */
+ audit_fd = audit_open();
+ if (audit_fd < 0)
+ FatalError("XSELinux: Failed to open the system audit log\n");
+
+ /* Allocate private storage */
+ if (!dixRequestPrivate(stateKey, sizeof(SELinuxStateRec)))
+ FatalError("XSELinux: Failed to allocate private storage.\n");
+
+ /* Create atoms for doing window labeling */
+ atom_ctx = MakeAtom("_SELINUX_CONTEXT", 16, TRUE);
+ if (atom_ctx == BAD_RESOURCE)
+ FatalError("XSELinux: Failed to create atom\n");
+ atom_client_ctx = MakeAtom("_SELINUX_CLIENT_CONTEXT", 23, TRUE);
+ if (atom_client_ctx == BAD_RESOURCE)
+ FatalError("XSELinux: Failed to create atom\n");
+
+ /* Register callbacks */
+ ret &= dixRegisterPrivateInitFunc(stateKey, SELinuxStateInit, NULL);
+ ret &= dixRegisterPrivateDeleteFunc(stateKey, SELinuxStateFree, NULL);
+
+ ret &= AddCallback(&ClientStateCallback, SELinuxClientState, NULL);
+ ret &= AddCallback(&ResourceStateCallback, SELinuxResourceState, NULL);
+ ret &= AddCallback(&SelectionCallback, SELinuxSelectionState, NULL);
+
+ ret &= XaceRegisterCallback(XACE_EXT_DISPATCH, SELinuxExtension, NULL);
+ ret &= XaceRegisterCallback(XACE_RESOURCE_ACCESS, SELinuxResource, NULL);
+ ret &= XaceRegisterCallback(XACE_DEVICE_ACCESS, SELinuxDevice, NULL);
+ ret &= XaceRegisterCallback(XACE_PROPERTY_ACCESS, SELinuxProperty, NULL);
+ ret &= XaceRegisterCallback(XACE_SEND_ACCESS, SELinuxSend, NULL);
+ ret &= XaceRegisterCallback(XACE_RECEIVE_ACCESS, SELinuxReceive, NULL);
+ ret &= XaceRegisterCallback(XACE_CLIENT_ACCESS, SELinuxClient, NULL);
+ ret &= XaceRegisterCallback(XACE_EXT_ACCESS, SELinuxExtension, NULL);
+ ret &= XaceRegisterCallback(XACE_SERVER_ACCESS, SELinuxServer, NULL);
+ ret &= XaceRegisterCallback(XACE_SELECTION_ACCESS, SELinuxSelection, NULL);
+ ret &= XaceRegisterCallback(XACE_SCREEN_ACCESS, SELinuxScreen, NULL);
+ ret &= XaceRegisterCallback(XACE_SCREENSAVER_ACCESS, SELinuxScreen, truep);
+ if (!ret)
+ FatalError("XSELinux: Failed to register one or more callbacks\n");
+
+ /* Add extension to server */
+ extEntry = AddExtension(XSELINUX_EXTENSION_NAME,
+ XSELinuxNumberEvents, XSELinuxNumberErrors,
+ ProcSELinuxDispatch, SProcSELinuxDispatch,
+ SELinuxResetProc, StandardMinorOpcode);
+
+ /* Label objects that were created before we could register ourself */
+ SELinuxLabelInitial();
+}
diff --git a/Xext/xselinux.h b/Xext/xselinux.h
new file mode 100644
index 000000000..ebcc4aae0
--- /dev/null
+++ b/Xext/xselinux.h
@@ -0,0 +1,195 @@
+/************************************************************
+
+Author: Eamon Walsh <ewalsh@epoch.ncsc.mil>
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+this permission notice appear in supporting documentation. This permission
+notice shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+********************************************************/
+
+#ifndef _XSELINUX_H
+#define _XSELINUX_H
+
+#include "dixaccess.h"
+
+/* Extension info */
+#define XSELINUX_EXTENSION_NAME "SELinux"
+#define XSELINUX_MAJOR_VERSION 1
+#define XSELINUX_MINOR_VERSION 0
+#define XSELinuxNumberEvents 0
+#define XSELinuxNumberErrors 0
+
+/* Extension protocol */
+#define X_SELinuxQueryVersion 0
+#define X_SELinuxSetSelectionManager 1
+#define X_SELinuxGetSelectionManager 2
+#define X_SELinuxSetDeviceCreateContext 3
+#define X_SELinuxGetDeviceCreateContext 4
+#define X_SELinuxSetDeviceContext 5
+#define X_SELinuxGetDeviceContext 6
+#define X_SELinuxSetPropertyCreateContext 7
+#define X_SELinuxGetPropertyCreateContext 8
+#define X_SELinuxGetPropertyContext 9
+#define X_SELinuxSetWindowCreateContext 10
+#define X_SELinuxGetWindowCreateContext 11
+#define X_SELinuxGetWindowContext 12
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 SELinuxReqType;
+ CARD16 length;
+ CARD8 client_major;
+ CARD8 client_minor;
+ CARD16 unused;
+} SELinuxQueryVersionReq;
+
+typedef struct {
+ CARD8 type;
+ CARD8 pad1;
+ CARD16 sequenceNumber;
+ CARD32 length;
+ CARD16 server_major;
+ CARD16 server_minor;
+ CARD32 pad2;
+ CARD32 pad3;
+ CARD32 pad4;
+ CARD32 pad5;
+ CARD32 pad6;
+} SELinuxQueryVersionReply;
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 SELinuxReqType;
+ CARD16 length;
+ CARD32 window;
+} SELinuxSetSelectionManagerReq;
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 SELinuxReqType;
+ CARD16 length;
+} SELinuxGetSelectionManagerReq;
+
+typedef struct {
+ CARD8 type;
+ CARD8 pad1;
+ CARD16 sequenceNumber;
+ CARD32 length;
+ CARD32 window;
+ CARD32 pad2;
+ CARD32 pad3;
+ CARD32 pad4;
+ CARD32 pad5;
+ CARD32 pad6;
+} SELinuxGetSelectionManagerReply;
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 SELinuxReqType;
+ CARD16 length;
+ CARD8 permanent;
+ CARD8 unused;
+ CARD16 context_len;
+} SELinuxSetCreateContextReq;
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 SELinuxReqType;
+ CARD16 length;
+} SELinuxGetCreateContextReq;
+
+typedef struct {
+ CARD8 type;
+ CARD8 permanent;
+ CARD16 sequenceNumber;
+ CARD32 length;
+ CARD16 context_len;
+ CARD16 pad1;
+ CARD32 pad2;
+ CARD32 pad3;
+ CARD32 pad4;
+ CARD32 pad5;
+ CARD32 pad6;
+} SELinuxGetCreateContextReply;
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 SELinuxReqType;
+ CARD16 length;
+ CARD32 id;
+ CARD16 unused;
+ CARD16 context_len;
+} SELinuxSetContextReq;
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 SELinuxReqType;
+ CARD16 length;
+ CARD32 id;
+} SELinuxGetContextReq;
+
+typedef struct {
+ CARD8 type;
+ CARD8 pad1;
+ CARD16 sequenceNumber;
+ CARD32 length;
+ CARD16 context_len;
+ CARD16 pad2;
+ CARD32 pad3;
+ CARD32 pad4;
+ CARD32 pad5;
+ CARD32 pad6;
+ CARD32 pad7;
+} SELinuxGetContextReply;
+
+typedef struct {
+ CARD8 reqType;
+ CARD8 SELinuxReqType;
+ CARD16 length;
+ CARD32 window;
+ CARD32 property;
+} SELinuxGetPropertyContextReq;
+
+typedef struct {
+ CARD8 type;
+ CARD8 pad1;
+ CARD16 sequenceNumber;
+ CARD32 length;
+ CARD16 context_len;
+ CARD16 pad2;
+ CARD32 pad3;
+ CARD32 pad4;
+ CARD32 pad5;
+ CARD32 pad6;
+ CARD32 pad7;
+} SELinuxGetPropertyContextReply;
+
+
+/* Private Flask definitions */
+#define SECCLASS_X_DRAWABLE 1
+#define SECCLASS_X_SCREEN 2
+#define SECCLASS_X_GC 3
+#define SECCLASS_X_FONT 4
+#define SECCLASS_X_COLORMAP 5
+#define SECCLASS_X_PROPERTY 6
+#define SECCLASS_X_SELECTION 7
+#define SECCLASS_X_CURSOR 8
+#define SECCLASS_X_CLIENT 9
+#define SECCLASS_X_DEVICE 10
+#define SECCLASS_X_SERVER 11
+#define SECCLASS_X_EXTENSION 12
+#define SECCLASS_X_EVENT 13
+#define SECCLASS_X_FAKEEVENT 14
+#define SECCLASS_X_RESOURCE 15
+
+#endif /* _XSELINUX_H */
diff --git a/Xext/xtest.c b/Xext/xtest.c
index 96ae18225..db6d54543 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -49,7 +49,6 @@ from The Open Group.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#define EXTENSION_EVENT_BASE 64
-#include "extinit.h" /* LookupDeviceIntRec */
#endif /* XINPUT */
#include "modinit.h"
@@ -85,9 +84,9 @@ static DISPATCH_PROC(SProcXTestGrabControl);
void
XTestExtensionInit(INITARGS)
{
- (void) AddExtension(XTestExtensionName, 0, 0,
- ProcXTestDispatch, SProcXTestDispatch,
- XTestResetProc, StandardMinorOpcode);
+ AddExtension(XTestExtensionName, 0, 0,
+ ProcXTestDispatch, SProcXTestDispatch,
+ XTestResetProc, StandardMinorOpcode);
}
/*ARGSUSED*/
@@ -129,7 +128,7 @@ ProcXTestCompareCursor(client)
register int n, rc;
REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
if (stuff->cursor == None)
@@ -137,11 +136,12 @@ ProcXTestCompareCursor(client)
else if (stuff->cursor == XTestCurrentCursor)
pCursor = GetSpriteCursor();
else {
- pCursor = (CursorPtr)LookupIDByType(stuff->cursor, RT_CURSOR);
- if (!pCursor)
+ rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
+ client, DixReadAccess);
+ if (rc != Success)
{
client->errorValue = stuff->cursor;
- return (BadCursor);
+ return (rc == BadValue) ? BadCursor : rc;
}
}
rep.type = X_Reply;
@@ -273,11 +273,12 @@ ProcXTestFakeInput(client)
#ifdef XINPUT
if (extension)
{
- dev = LookupDeviceIntRec(stuff->deviceid & 0177);
- if (!dev)
+ rc = dixLookupDevice(&dev, stuff->deviceid & 0177, client,
+ DixWriteAccess);
+ if (rc != Success)
{
client->errorValue = stuff->deviceid & 0177;
- return BadValue;
+ return rc;
}
if (nev > 1)
{
@@ -303,7 +304,7 @@ ProcXTestFakeInput(client)
#ifdef XINPUT
if (!extension)
#endif /* XINPUT */
- dev = (DeviceIntPtr)LookupKeyboardDevice();
+ dev = inputInfo.keyboard;
if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode ||
ev->u.u.detail > dev->key->curKeySyms.maxKeyCode)
{
@@ -347,13 +348,13 @@ ProcXTestFakeInput(client)
break;
}
#endif /* XINPUT */
- dev = (DeviceIntPtr)LookupPointerDevice();
+ dev = inputInfo.pointer;
if (ev->u.keyButtonPointer.root == None)
root = GetCurrentRootWindow();
else
{
rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root, client,
- DixUnknownAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
if (root->parent)
@@ -436,7 +437,7 @@ ProcXTestFakeInput(client)
#ifdef XINPUT
if (!extension)
#endif /* XINPUT */
- dev = (DeviceIntPtr)LookupPointerDevice();
+ dev = inputInfo.pointer;
if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons)
{
client->errorValue = ev->u.u.detail;
@@ -445,7 +446,7 @@ ProcXTestFakeInput(client)
break;
}
if (screenIsSaved == SCREEN_SAVER_ON)
- SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
+ dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
ev->u.keyButtonPointer.time = currentTime.milliseconds;
(*dev->public.processInputProc)(ev, dev, nev);
return client->noClientException;
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index ee2e051d4..8096c8c14 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -387,13 +387,13 @@ ProcXvQueryAdaptors(ClientPtr client)
REQUEST(xvQueryAdaptorsReq);
REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
pScreen = pWin->drawable.pScreen;
- pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
-
+ pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ XvGetScreenKey());
if (!pxvs)
{
rep.type = X_Reply;
@@ -537,7 +537,7 @@ ProcXvPutVideo(ClientPtr client)
REQUEST(xvPutVideoReq);
REQUEST_SIZE_MATCH(xvPutVideoReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
@@ -582,7 +582,7 @@ ProcXvPutStill(ClientPtr client)
REQUEST(xvPutStillReq);
REQUEST_SIZE_MATCH(xvPutStillReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
@@ -627,7 +627,7 @@ ProcXvGetVideo(ClientPtr client)
REQUEST(xvGetVideoReq);
REQUEST_SIZE_MATCH(xvGetVideoReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
@@ -672,7 +672,7 @@ ProcXvGetStill(ClientPtr client)
REQUEST(xvGetStillReq);
REQUEST_SIZE_MATCH(xvGetStillReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
@@ -714,7 +714,7 @@ ProcXvSelectVideoNotify(ClientPtr client)
REQUEST(xvSelectVideoNotifyReq);
REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
- rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixUnknownAccess);
+ rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReceiveAccess);
if (rc != Success)
return rc;
@@ -826,7 +826,7 @@ ProcXvStopVideo(ClientPtr client)
return (status);
}
- rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixUnknownAccess);
+ rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
if (rc != Success)
return rc;
@@ -1024,7 +1024,7 @@ ProcXvPutImage(ClientPtr client)
REQUEST(xvPutImageReq);
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
@@ -1112,7 +1112,7 @@ ProcXvShmPutImage(ClientPtr client)
REQUEST(xvShmPutImageReq);
REQUEST_SIZE_MATCH(xvShmPutImageReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
{
@@ -1921,7 +1921,8 @@ XineramaXvPutStill(ClientPtr client)
void XineramifyXv(void)
{
ScreenPtr pScreen, screen0 = screenInfo.screens[0];
- XvScreenPtr xvsp0 = (XvScreenPtr)screen0->devPrivates[XvScreenIndex].ptr;
+ XvScreenPtr xvsp0 = (XvScreenPtr)dixLookupPrivate(&screen0->devPrivates,
+ XvGetScreenKey());
XvAdaptorPtr refAdapt, pAdapt;
XvAttributePtr pAttr;
XvScreenPtr xvsp;
@@ -1954,8 +1955,8 @@ void XineramifyXv(void)
for(j = 1; j < PanoramiXNumScreens; j++) {
pScreen = screenInfo.screens[j];
- xvsp = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
-
+ xvsp = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ XvGetScreenKey());
/* Do not try to go on if xv is not supported on this screen */
if (xvsp==NULL) continue ;
diff --git a/Xext/xvdix.h b/Xext/xvdix.h
index 9e94e05d5..a516cf113 100644
--- a/Xext/xvdix.h
+++ b/Xext/xvdix.h
@@ -55,7 +55,6 @@ SOFTWARE.
#include "scrnintstr.h"
#include <X11/extensions/Xvproto.h>
-extern int XvScreenIndex;
extern unsigned long XvExtensionGeneration;
extern unsigned long XvScreenGeneration;
extern unsigned long XvResourceGeneration;
@@ -224,10 +223,8 @@ typedef struct {
DevUnion devPriv;
} XvScreenRec, *XvScreenPtr;
-#define SCREEN_PROLOGUE(pScreen, field)\
- ((pScreen)->field = \
- ((XvScreenPtr) \
- (pScreen)->devPrivates[XvScreenIndex].ptr)->field)
+#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, XvScreenKey))->field)
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
@@ -242,7 +239,7 @@ extern int SProcXvDispatch(ClientPtr);
extern void XvExtensionInit(void);
extern int XvScreenInit(ScreenPtr);
-extern int XvGetScreenIndex(void);
+extern DevPrivateKey XvGetScreenKey(void);
extern unsigned long XvGetRTPort(void);
extern int XvdiSendPortNotify(XvPortPtr, Atom, INT32);
extern int XvdiVideoStopped(XvPortPtr, int);
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index 1b80bc8da..9834fcfa0 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -105,7 +105,7 @@ SOFTWARE.
#endif
#include "xvdisp.h"
-int XvScreenIndex = -1;
+static DevPrivateKey XvScreenKey = &XvScreenKey;
unsigned long XvExtensionGeneration = 0;
unsigned long XvScreenGeneration = 0;
unsigned long XvResourceGeneration = 0;
@@ -166,12 +166,6 @@ XvExtensionInit(void)
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
@@ -265,19 +259,13 @@ XvScreenInit(ScreenPtr pScreen)
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)
+ if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey))
{
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
}
@@ -291,7 +279,7 @@ XvScreenInit(ScreenPtr pScreen)
return BadAlloc;
}
- pScreen->devPrivates[XvScreenIndex].ptr = (pointer)pxvs;
+ dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
pxvs->DestroyPixmap = pScreen->DestroyPixmap;
@@ -313,7 +301,7 @@ XvCloseScreen(
XvScreenPtr pxvs;
- pxvs = (XvScreenPtr) pScreen->devPrivates[XvScreenIndex].ptr;
+ pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
pScreen->DestroyPixmap = pxvs->DestroyPixmap;
pScreen->DestroyWindow = pxvs->DestroyWindow;
@@ -323,7 +311,7 @@ XvCloseScreen(
xfree(pxvs);
- pScreen->devPrivates[XvScreenIndex].ptr = (pointer)NULL;
+ dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL);
return (*pScreen->CloseScreen)(ii, pScreen);
}
@@ -334,10 +322,10 @@ XvResetProc(ExtensionEntry* extEntry)
XvResetProcVector();
}
-_X_EXPORT int
-XvGetScreenIndex(void)
+_X_EXPORT DevPrivateKey
+XvGetScreenKey(void)
{
- return XvScreenIndex;
+ return XvScreenKey;
}
_X_EXPORT unsigned long
@@ -361,7 +349,7 @@ XvDestroyPixmap(PixmapPtr pPix)
SCREEN_PROLOGUE(pScreen, DestroyPixmap);
- pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
+ pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
/* CHECK TO SEE IF THIS PORT IS IN USE */
@@ -413,7 +401,7 @@ XvDestroyWindow(WindowPtr pWin)
SCREEN_PROLOGUE(pScreen, DestroyWindow);
- pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
+ pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
/* CHECK TO SEE IF THIS PORT IS IN USE */
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index ae358936e..7ae8cc0da 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -39,7 +39,7 @@
#define DR_CLIENT_DRIVER_NAME_SIZE 48
#define DR_BUSID_SIZE 48
-int XvMCScreenIndex = -1;
+static DevPrivateKey XvMCScreenKey = NULL;
unsigned long XvMCGeneration = 0;
@@ -63,7 +63,7 @@ typedef struct {
} XvMCScreenRec, *XvMCScreenPtr;
#define XVMC_GET_PRIVATE(pScreen) \
- (XvMCScreenPtr)((pScreen)->devPrivates[XvMCScreenIndex].ptr)
+ (XvMCScreenPtr)(dixLookupPrivate(&(pScreen)->devPrivates, XvMCScreenKey))
static int
@@ -153,7 +153,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
return _XvBadPort;
}
- if(XvMCScreenIndex >= 0) { /* any adaptors at all */
+ if(XvMCScreenKey) { /* 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++) {
@@ -211,7 +211,7 @@ ProcXvMCCreateContext(ClientPtr client)
pScreen = pPort->pAdaptor->pScreen;
- if(XvMCScreenIndex < 0) /* no XvMC adaptors */
+ if(XvMCScreenKey == NULL) /* no XvMC adaptors */
return BadMatch;
if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */
@@ -494,7 +494,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
pScreen = pPort->pAdaptor->pScreen;
- if(XvMCScreenIndex < 0) /* No XvMC adaptors */
+ if(XvMCScreenKey == NULL) /* No XvMC adaptors */
return BadMatch;
if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
@@ -679,7 +679,7 @@ XvMCExtensionInit(void)
{
ExtensionEntry *extEntry;
- if(XvMCScreenIndex < 0) /* nobody supports it */
+ if(XvMCScreenKey == NULL) /* nobody supports it */
return;
if(!(XvMCRTContext = CreateNewResourceType(XvMCDestroyContextRes)))
@@ -720,17 +720,12 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
{
XvMCScreenPtr pScreenPriv;
- if(XvMCGeneration != serverGeneration) {
- if((XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return BadAlloc;
-
- XvMCGeneration = serverGeneration;
- }
+ XvMCScreenKey = &XvMCScreenKey;
if(!(pScreenPriv = (XvMCScreenPtr)xalloc(sizeof(XvMCScreenRec))))
return BadAlloc;
- pScreen->devPrivates[XvMCScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = XvMCCloseScreen;
@@ -754,7 +749,7 @@ XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
XvMCAdaptorPtr adaptor = NULL;
int i;
- if(XvMCScreenIndex < 0) return NULL;
+ if(XvMCScreenKey == NULL) return NULL;
if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
return NULL;
diff --git a/Xi/allowev.c b/Xi/allowev.c
index cf075e112..0043cb138 100644
--- a/Xi/allowev.c
+++ b/Xi/allowev.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "allowev.h"
@@ -95,13 +94,14 @@ ProcXAllowDeviceEvents(ClientPtr client)
{
TimeStamp time;
DeviceIntPtr thisdev;
+ int rc;
REQUEST(xAllowDeviceEventsReq);
REQUEST_SIZE_MATCH(xAllowDeviceEventsReq);
- thisdev = LookupDeviceIntRec(stuff->deviceid);
- if (thisdev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&thisdev, stuff->deviceid, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
time = ClientTimeToServerTime(stuff->time);
switch (stuff->mode) {
diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index 055f459d0..e7d04a781 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -61,7 +61,6 @@ SOFTWARE.
#include <X11/extensions/XIproto.h> /* control constants */
#include "XIstubs.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "exevents.h"
@@ -112,11 +111,9 @@ ProcXChangeDeviceControl(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL) {
- ret = BadDevice;
+ ret = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
+ if (ret != Success)
goto out;
- }
rep.repType = X_Reply;
rep.RepType = X_ChangeDeviceControl;
diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c
index 46bb8e78f..8fc24d5ff 100644
--- a/Xi/chgfctl.c
+++ b/Xi/chgfctl.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* control constants */
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "chgfctl.h"
@@ -444,14 +443,15 @@ ProcXChangeFeedbackControl(ClientPtr client)
StringFeedbackPtr s;
BellFeedbackPtr b;
LedFeedbackPtr l;
+ int rc;
REQUEST(xChangeFeedbackControlReq);
REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq);
len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
switch (stuff->feedbackid) {
case KbdFeedbackClass:
diff --git a/Xi/chgkmap.c b/Xi/chgkmap.c
index bfdc1cedc..3361e9801 100644
--- a/Xi/chgkmap.c
+++ b/Xi/chgkmap.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -107,9 +106,9 @@ ProcXChangeDeviceKeyMapping(ClientPtr client)
REQUEST(xChangeDeviceKeyMappingReq);
REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ ret = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
+ if (ret != Success)
+ return ret;
len = stuff->length - (sizeof(xChangeDeviceKeyMappingReq) >> 2);
ret = ChangeKeyMapping(client, dev, len, DeviceMappingNotify,
diff --git a/Xi/chgprop.c b/Xi/chgprop.c
index 13463dd1c..58db88620 100644
--- a/Xi/chgprop.c
+++ b/Xi/chgprop.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h"
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -115,7 +114,7 @@ ProcXChangeDeviceDontPropagateList(ClientPtr client)
stuff->count)
return BadLength;
- rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xi/chgptr.c b/Xi/chgptr.c
index 2ce81d1d6..28950918f 100644
--- a/Xi/chgptr.c
+++ b/Xi/chgptr.c
@@ -63,8 +63,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include "scrnintstr.h" /* screen structure */
-#include "extinit.h" /* LookupDeviceIntRec */
-
#include "dixevents.h"
#include "exevents.h"
#include "exglobals.h"
diff --git a/Xi/closedev.c b/Xi/closedev.c
index 1ec3fa163..b2b5f69a6 100644
--- a/Xi/closedev.c
+++ b/Xi/closedev.c
@@ -62,7 +62,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "closedev.h"
@@ -140,16 +139,16 @@ DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client)
int
ProcXCloseDevice(ClientPtr client)
{
- int i;
+ int rc, i;
WindowPtr pWin, p1;
DeviceIntPtr d;
REQUEST(xCloseDeviceReq);
REQUEST_SIZE_MATCH(xCloseDeviceReq);
- d = LookupDeviceIntRec(stuff->deviceid);
- if (d == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&d, stuff->deviceid, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
if (d->grab && SameClient(d->grab, client))
(*d->DeactivateGrab) (d); /* release active grab */
diff --git a/Xi/devbell.c b/Xi/devbell.c
index 83e844d93..264f64800 100644
--- a/Xi/devbell.c
+++ b/Xi/devbell.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "devbell.h"
@@ -93,7 +92,7 @@ ProcXDeviceBell(ClientPtr client)
DeviceIntPtr dev;
KbdFeedbackPtr k;
BellFeedbackPtr b;
- int base;
+ int rc, base;
int newpercent;
CARD8 class;
pointer ctrl;
@@ -102,10 +101,10 @@ ProcXDeviceBell(ClientPtr client)
REQUEST(xDeviceBellReq);
REQUEST_SIZE_MATCH(xDeviceBellReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL) {
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixBellAccess);
+ if (rc != Success) {
client->errorValue = stuff->deviceid;
- return BadDevice;
+ return rc;
}
if (stuff->percent < -100 || stuff->percent > 100) {
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 7cf0c50a5..ac6b92383 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -67,11 +67,11 @@ SOFTWARE.
#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 "scrnintstr.h"
+#include "xace.h"
#ifdef XKB
#include "xkbsrv.h"
@@ -511,6 +511,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
WindowPtr pWin, confineTo;
CursorPtr cursor;
GrabPtr grab;
+ Mask access_mode = DixGrabAccess;
int rc;
if ((this_device_mode != GrabModeSync) &&
@@ -531,25 +532,33 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
client->errorValue = ownerEvents;
return BadValue;
}
- rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (rconfineTo == None)
confineTo = NullWindow;
else {
- rc = dixLookupWindow(&confineTo, rconfineTo, client, DixUnknownAccess);
+ rc = dixLookupWindow(&confineTo, rconfineTo, client, DixSetAttrAccess);
if (rc != Success)
return rc;
}
if (rcursor == None)
cursor = NullCursor;
else {
- cursor = (CursorPtr) LookupIDByType(rcursor, RT_CURSOR);
- if (!cursor) {
+ rc = dixLookupResource((pointer *)&cursor, rcursor, RT_CURSOR,
+ client, DixUseAccess);
+ if (rc != Success)
+ {
client->errorValue = rcursor;
- return BadCursor;
+ return (rc == BadValue) ? BadCursor : rc;
}
+ access_mode |= DixForceAccess;
}
+ if (this_device_mode == GrabModeSync || other_devices_mode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
+ if (rc != Success)
+ return rc;
grab = CreateGrab(client->index, dev, pWin, eventMask,
(Bool) ownerEvents, (Bool) this_device_mode,
@@ -557,7 +566,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
DeviceButtonPress, button, confineTo, cursor);
if (!grab)
return BadAlloc;
- return AddPassiveGrabToList(grab);
+ return AddPassiveGrabToList(client, grab);
}
int
@@ -569,6 +578,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
WindowPtr pWin;
GrabPtr grab;
KeyClassPtr k = dev->key;
+ Mask access_mode = DixGrabAccess;
int rc;
if (k == NULL)
@@ -596,7 +606,12 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
client->errorValue = ownerEvents;
return BadValue;
}
- rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, grabWindow, client, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+ if (this_device_mode == GrabModeSync || other_devices_mode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc != Success)
return rc;
@@ -606,7 +621,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
NullWindow, NullCursor);
if (!grab)
return BadAlloc;
- return AddPassiveGrabToList(grab);
+ return AddPassiveGrabToList(client, grab);
}
int
@@ -837,7 +852,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate,
if (!mask)
break;
}
- } else
+ } else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, ev, count))
(void)(DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, d->id));
return Success;
}
@@ -1101,7 +1116,8 @@ MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask)
{
DeviceIntPtr dev;
- dev = LookupDeviceIntRec(pEvents->deviceid & DEVICE_BITS);
+ dixLookupDevice(&dev, pEvents->deviceid & DEVICE_BITS, serverClient,
+ DixReadAccess);
if (!dev)
return 0;
@@ -1125,7 +1141,8 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type,
{
DeviceIntPtr dev;
- dev = LookupDeviceIntRec(xE->deviceid & DEVICE_BITS);
+ dixLookupDevice(&dev, xE->deviceid & DEVICE_BITS, serverClient,
+ DixReadAccess);
if (!dev)
return;
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 73bae5e85..2ffdafbc1 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -69,6 +69,7 @@ SOFTWARE.
#include "extinit.h"
#include "exglobals.h"
#include "swaprep.h"
+#include "registry.h"
/* modules local to Xi */
#include "allowev.h"
@@ -856,29 +857,6 @@ MakeDeviceTypeAtoms(void)
MakeAtom(dev_type[i].name, strlen(dev_type[i].name), 1);
}
-/**************************************************************************
- * Return a DeviceIntPtr corresponding to a specified device id.
- *
- */
-
-DeviceIntPtr
-LookupDeviceIntRec(CARD8 id)
-{
- DeviceIntPtr dev;
-
- for (dev = inputInfo.devices; dev; dev = dev->next) {
- if (dev->id == id)
- return dev;
- }
-
- for (dev = inputInfo.off_devices; dev; dev = dev->next) {
- if (dev->id == id)
- return dev;
- }
-
- return NULL;
-}
-
/*****************************************************************************
*
* SEventIDispatch
@@ -959,6 +937,7 @@ XInputExtensionInit(void)
AllExtensionVersions[IReqCode - 128] = thisversion;
MakeDeviceTypeAtoms();
RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone);
+ RegisterResourceName(RT_INPUTCLIENT, "INPUTCLIENT");
FixExtensionEvents(extEntry);
ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch;
EventSwapVector[DeviceValuator] = SEventIDispatch;
diff --git a/Xi/getbmap.c b/Xi/getbmap.c
index ebb0613af..9f93b06ef 100644
--- a/Xi/getbmap.c
+++ b/Xi/getbmap.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getbmap.h"
@@ -92,6 +91,7 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
DeviceIntPtr dev;
xGetDeviceButtonMappingReply rep;
ButtonClassPtr b;
+ int rc;
REQUEST(xGetDeviceButtonMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceButtonMappingReq);
@@ -102,9 +102,9 @@ ProcXGetDeviceButtonMapping(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
b = dev->button;
if (b == NULL)
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index 7175dc253..6e1e3ef58 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getdctl.h"
@@ -238,7 +237,7 @@ SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep)
int
ProcXGetDeviceControl(ClientPtr client)
{
- int total_length = 0;
+ int rc, total_length = 0;
char *buf, *savbuf;
DeviceIntPtr dev;
xGetDeviceControlReply rep;
@@ -246,9 +245,9 @@ ProcXGetDeviceControl(ClientPtr client)
REQUEST(xGetDeviceControlReq);
REQUEST_SIZE_MATCH(xGetDeviceControlReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
rep.repType = X_Reply;
rep.RepType = X_GetDeviceControl;
diff --git a/Xi/getfctl.c b/Xi/getfctl.c
index 7dff32f4f..1b1e594a2 100644
--- a/Xi/getfctl.c
+++ b/Xi/getfctl.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getfctl.h"
@@ -290,7 +289,7 @@ SRepXGetFeedbackControl(ClientPtr client, int size,
int
ProcXGetFeedbackControl(ClientPtr client)
{
- int total_length = 0;
+ int rc, total_length = 0;
char *buf, *savbuf;
DeviceIntPtr dev;
KbdFeedbackPtr k;
@@ -304,9 +303,9 @@ ProcXGetFeedbackControl(ClientPtr client)
REQUEST(xGetFeedbackControlReq);
REQUEST_SIZE_MATCH(xGetFeedbackControlReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
rep.repType = X_Reply;
rep.RepType = X_GetFeedbackControl;
diff --git a/Xi/getfocus.c b/Xi/getfocus.c
index 073913bf2..dfef22fb7 100644
--- a/Xi/getfocus.c
+++ b/Xi/getfocus.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getfocus.h"
@@ -93,12 +92,15 @@ ProcXGetDeviceFocus(ClientPtr client)
DeviceIntPtr dev;
FocusClassPtr focus;
xGetDeviceFocusReply rep;
+ int rc;
REQUEST(xGetDeviceFocusReq);
REQUEST_SIZE_MATCH(xGetDeviceFocusReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL || !dev->focus)
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetFocusAccess);
+ if (rc != Success)
+ return rc;
+ if (!dev->focus)
return BadDevice;
rep.repType = X_Reply;
diff --git a/Xi/getkmap.c b/Xi/getkmap.c
index eaa0cffcc..0eec1d8df 100644
--- a/Xi/getkmap.c
+++ b/Xi/getkmap.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "swaprep.h"
@@ -94,13 +93,14 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
xGetDeviceKeyMappingReply rep;
DeviceIntPtr dev;
KeySymsPtr k;
+ int rc;
REQUEST(xGetDeviceKeyMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceKeyMappingReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
if (dev->key == NULL)
return BadMatch;
k = &dev->key->curKeySyms;
diff --git a/Xi/getmmap.c b/Xi/getmmap.c
index 8a99d63ed..c6c9c3362 100644
--- a/Xi/getmmap.c
+++ b/Xi/getmmap.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h> /* Request macro */
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getmmap.h"
@@ -94,13 +93,14 @@ ProcXGetDeviceModifierMapping(ClientPtr client)
DeviceIntPtr dev;
xGetDeviceModifierMappingReply rep;
KeyClassPtr kp;
+ int rc;
REQUEST(xGetDeviceModifierMappingReq);
REQUEST_SIZE_MATCH(xGetDeviceModifierMappingReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
kp = dev->key;
if (kp == NULL)
diff --git a/Xi/getprop.c b/Xi/getprop.c
index 531e65f27..188f549e5 100644
--- a/Xi/getprop.c
+++ b/Xi/getprop.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h" /* window structs */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "swaprep.h"
@@ -112,7 +111,7 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
rep.length = 0;
rep.count = 0;
- rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xi/getselev.c b/Xi/getselev.c
index 819b2dbd0..caa376fcb 100644
--- a/Xi/getselev.c
+++ b/Xi/getselev.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window struct */
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "swaprep.h"
@@ -114,7 +113,7 @@ ProcXGetSelectedExtensionEvents(ClientPtr client)
rep.this_client_count = 0;
rep.all_clients_count = 0;
- rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xi/getvers.c b/Xi/getvers.c
index a223a5d1e..a4afe808f 100644
--- a/Xi/getvers.c
+++ b/Xi/getvers.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "getvers.h"
diff --git a/Xi/grabdev.c b/Xi/grabdev.c
index b303695fd..110fc6b5f 100644
--- a/Xi/grabdev.c
+++ b/Xi/grabdev.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "dixevents.h" /* GrabDevice */
@@ -122,9 +121,9 @@ ProcXGrabDevice(ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.length = 0;
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess);
+ if (rc != Success)
+ return rc;
if ((rc = CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->event_count, tmp, dev,
@@ -153,7 +152,7 @@ int
CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
struct tmask *mask, DeviceIntPtr dev, int req)
{
- int i, j;
+ int rc, i, j;
int device;
DeviceIntPtr tdev;
@@ -167,8 +166,10 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
if (device > 255)
return BadClass;
- tdev = LookupDeviceIntRec(device);
- if (tdev == NULL || (dev != NULL && tdev != dev))
+ rc = dixLookupDevice(&tdev, device, client, DixReadAccess);
+ if (rc != BadDevice && rc != Success)
+ return rc;
+ if (rc == BadDevice || (dev != NULL && tdev != dev))
return BadClass;
for (j = 0; j < ExtEventIndex; j++)
diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c
index 21e46fceb..c2661e85b 100644
--- a/Xi/grabdevb.c
+++ b/Xi/grabdevb.c
@@ -61,8 +61,8 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
+#include "xace.h"
#include "grabdev.h"
#include "grabdevb.h"
@@ -117,18 +117,23 @@ ProcXGrabDeviceButton(ClientPtr client)
(sizeof(xGrabDeviceButtonReq) >> 2) + stuff->event_count)
return BadLength;
- dev = LookupDeviceIntRec(stuff->grabbed_device);
- if (dev == NULL)
- return BadDevice;
+ ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
+ if (ret != Success)
+ return ret;
if (stuff->modifier_device != UseXKeyboard) {
- mdev = LookupDeviceIntRec(stuff->modifier_device);
- if (mdev == NULL)
- return BadDevice;
+ ret = dixLookupDevice(&mdev, stuff->modifier_device, client,
+ DixReadAccess);
+ if (ret != Success)
+ return ret;
if (mdev->key == NULL)
return BadMatch;
- } else
- mdev = (DeviceIntPtr) LookupKeyboardDevice();
+ } else {
+ mdev = inputInfo.keyboard;
+ ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixReadAccess);
+ if (ret != Success)
+ return ret;
+ }
class = (XEventClass *) (&stuff[1]); /* first word of values */
diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c
index 8da36ba8f..43b19280d 100644
--- a/Xi/grabdevk.c
+++ b/Xi/grabdevk.c
@@ -61,8 +61,8 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
+#include "xace.h"
#include "grabdev.h"
#include "grabdevk.h"
@@ -115,18 +115,23 @@ ProcXGrabDeviceKey(ClientPtr client)
if (stuff->length != (sizeof(xGrabDeviceKeyReq) >> 2) + stuff->event_count)
return BadLength;
- dev = LookupDeviceIntRec(stuff->grabbed_device);
- if (dev == NULL)
- return BadDevice;
+ ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
+ if (ret != Success)
+ return ret;
if (stuff->modifier_device != UseXKeyboard) {
- mdev = LookupDeviceIntRec(stuff->modifier_device);
- if (mdev == NULL)
- return BadDevice;
+ ret = dixLookupDevice(&mdev, stuff->modifier_device, client,
+ DixReadAccess);
+ if (ret != Success)
+ return ret;
if (mdev->key == NULL)
return BadMatch;
- } else
- mdev = (DeviceIntPtr) LookupKeyboardDevice();
+ } else {
+ mdev = inputInfo.keyboard;
+ ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixReadAccess);
+ if (ret != Success)
+ return ret;
+ }
class = (XEventClass *) (&stuff[1]); /* first word of values */
diff --git a/Xi/gtmotion.c b/Xi/gtmotion.c
index ad2bec391..4f4d7cb77 100644
--- a/Xi/gtmotion.c
+++ b/Xi/gtmotion.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -96,7 +95,7 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
INT32 *coords = NULL, *bufptr;
xGetDeviceMotionEventsReply rep;
unsigned long i;
- int num_events, axes, size = 0, tsize;
+ int rc, num_events, axes, size = 0, tsize;
unsigned long nEvents;
DeviceIntPtr dev;
TimeStamp start, stop;
@@ -106,9 +105,9 @@ ProcXGetDeviceMotionEvents(ClientPtr client)
REQUEST(xGetDeviceMotionEventsReq);
REQUEST_SIZE_MATCH(xGetDeviceMotionEventsReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
v = dev->valuator;
if (v == NULL || v->numAxes == 0)
return BadMatch;
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 160ad02fb..041de7635 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -63,8 +63,8 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h" /* FIXME */
+#include "xace.h"
#include "listdev.h"
@@ -310,7 +310,7 @@ ProcXListInputDevices(ClientPtr client)
xListInputDevicesReply rep;
int numdevs = 0;
int namesize = 1; /* need 1 extra byte for strcpy */
- int size = 0;
+ int rc, size = 0;
int total_length;
char *devbuf;
char *classbuf;
@@ -329,10 +329,16 @@ ProcXListInputDevices(ClientPtr client)
AddOtherInputDevices();
for (d = inputInfo.devices; d; d = d->next) {
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
SizeDeviceInfo(d, &namesize, &size);
numdevs++;
}
for (d = inputInfo.off_devices; d; d = d->next) {
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
SizeDeviceInfo(d, &namesize, &size);
numdevs++;
}
diff --git a/Xi/opendev.c b/Xi/opendev.c
index dfefe055c..128b1bd9c 100644
--- a/Xi/opendev.c
+++ b/Xi/opendev.c
@@ -61,7 +61,6 @@ SOFTWARE.
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
#include "windowstr.h" /* window structure */
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "opendev.h"
@@ -107,13 +106,15 @@ ProcXOpenDevice(ClientPtr client)
stuff->deviceid == inputInfo.keyboard->id)
return BadDevice;
- if ((dev = LookupDeviceIntRec(stuff->deviceid)) == NULL) { /* not open */
+ status = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
+ if (status == BadDevice) { /* not open */
for (dev = inputInfo.off_devices; dev; dev = dev->next)
if (dev->id == stuff->deviceid)
break;
if (dev == NULL)
return BadDevice;
- }
+ } else if (status != Success)
+ return status;
OpenInputDevice(dev, client, &status);
if (status != Success)
diff --git a/Xi/queryst.c b/Xi/queryst.c
index 2b66b7eb2..71ab79be8 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -42,7 +42,6 @@ from The Open Group.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -74,7 +73,7 @@ int
ProcXQueryDeviceState(ClientPtr client)
{
char n;
- int i;
+ int rc, i;
int num_classes = 0;
int total_length = 0;
char *buf, *savbuf;
@@ -96,9 +95,9 @@ ProcXQueryDeviceState(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
v = dev->valuator;
if (v != NULL && v->motionHintWindow != NULL)
diff --git a/Xi/selectev.c b/Xi/selectev.c
index a5cf56754..b93618ace 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -61,7 +61,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -164,7 +163,7 @@ ProcXSelectExtensionEvent(ClientPtr client)
if (stuff->length != (sizeof(xSelectExtensionEventReq) >> 2) + stuff->count)
return BadLength;
- ret = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+ ret = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess);
if (ret != Success)
return ret;
diff --git a/Xi/sendexev.c b/Xi/sendexev.c
index 20b415a1f..e4e38d790 100644
--- a/Xi/sendexev.c
+++ b/Xi/sendexev.c
@@ -59,9 +59,9 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* Window */
+#include "extnsionst.h" /* EventSwapPtr */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exevents.h"
#include "exglobals.h"
@@ -131,9 +131,9 @@ ProcXSendExtensionEvent(ClientPtr client)
(stuff->num_events * (sizeof(xEvent) >> 2)))
return BadLength;
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ ret = dixLookupDevice(&dev, stuff->deviceid, client, DixWriteAccess);
+ if (ret != Success)
+ return ret;
/* The client's event type must be one defined by an extension. */
diff --git a/Xi/setbmap.c b/Xi/setbmap.c
index 40f0f9a99..3035c649e 100644
--- a/Xi/setbmap.c
+++ b/Xi/setbmap.c
@@ -63,7 +63,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setbmap.h"
@@ -110,9 +109,9 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.status = MappingSuccess;
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ ret = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
+ if (ret != Success)
+ return ret;
ret = SetButtonMapping(client, dev, stuff->map_length, (BYTE *) & stuff[1]);
diff --git a/Xi/setdval.c b/Xi/setdval.c
index cb35b9157..b1e22fc21 100644
--- a/Xi/setdval.c
+++ b/Xi/setdval.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setdval.h"
@@ -92,6 +91,7 @@ ProcXSetDeviceValuators(ClientPtr client)
{
DeviceIntPtr dev;
xSetDeviceValuatorsReply rep;
+ int rc;
REQUEST(xSetDeviceValuatorsReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceValuatorsReq);
@@ -106,9 +106,9 @@ ProcXSetDeviceValuators(ClientPtr client)
stuff->num_valuators)
return BadLength;
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
if (dev->valuator == NULL)
return BadMatch;
diff --git a/Xi/setfocus.c b/Xi/setfocus.c
index 74de17e97..c6edbc2e5 100644
--- a/Xi/setfocus.c
+++ b/Xi/setfocus.c
@@ -63,7 +63,6 @@ SOFTWARE.
#include "dixevents.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setfocus.h"
@@ -102,8 +101,10 @@ ProcXSetDeviceFocus(ClientPtr client)
REQUEST(xSetDeviceFocusReq);
REQUEST_SIZE_MATCH(xSetDeviceFocusReq);
- dev = LookupDeviceIntRec(stuff->device);
- if (dev == NULL || !dev->focus)
+ ret = dixLookupDevice(&dev, stuff->device, client, DixSetFocusAccess);
+ if (ret != Success)
+ return ret;
+ if (!dev->focus)
return BadDevice;
ret = SetInputFocus(client, dev, stuff->focus, stuff->revertTo,
diff --git a/Xi/setmmap.c b/Xi/setmmap.c
index 19ec71bbe..be3d3cb6c 100644
--- a/Xi/setmmap.c
+++ b/Xi/setmmap.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "exevents.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setmmap.h"
@@ -99,9 +98,9 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
REQUEST(xSetDeviceModifierMappingReq);
REQUEST_AT_LEAST_SIZE(xSetDeviceModifierMappingReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ ret = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
+ if (ret != Success)
+ return ret;
rep.repType = X_Reply;
rep.RepType = X_SetDeviceModifierMapping;
diff --git a/Xi/setmode.c b/Xi/setmode.c
index 957721c66..8b6003ad0 100644
--- a/Xi/setmode.c
+++ b/Xi/setmode.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "setmode.h"
@@ -92,6 +91,7 @@ ProcXSetDeviceMode(ClientPtr client)
{
DeviceIntPtr dev;
xSetDeviceModeReply rep;
+ int rc;
REQUEST(xSetDeviceModeReq);
REQUEST_SIZE_MATCH(xSetDeviceModeReq);
@@ -101,9 +101,9 @@ ProcXSetDeviceMode(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
if (dev->valuator == NULL)
return BadMatch;
if ((dev->grab) && !SameClient(dev->grab, client))
diff --git a/Xi/stubs.c b/Xi/stubs.c
index 40cd02fe1..80ddd73c0 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -65,6 +65,7 @@ SOFTWARE.
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
#include "XIstubs.h"
+#include "xace.h"
/***********************************************************************
*
@@ -153,6 +154,7 @@ AddOtherInputDevices(void)
void
OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status)
{
+ *status = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess);
}
/****************************************************************************
diff --git a/Xi/ungrdev.c b/Xi/ungrdev.c
index 505d6690f..7abb1d061 100644
--- a/Xi/ungrdev.c
+++ b/Xi/ungrdev.c
@@ -59,7 +59,6 @@ SOFTWARE.
#include "inputstr.h" /* DeviceIntPtr */
#include "windowstr.h" /* window structure */
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "ungrdev.h"
@@ -94,13 +93,14 @@ ProcXUngrabDevice(ClientPtr client)
DeviceIntPtr dev;
GrabPtr grab;
TimeStamp time;
+ int rc;
REQUEST(xUngrabDeviceReq);
REQUEST_SIZE_MATCH(xUngrabDeviceReq);
- dev = LookupDeviceIntRec(stuff->deviceid);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
grab = dev->grab;
time = ClientTimeToServerTime(stuff->time);
diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c
index 0dfe805b7..590699f05 100644
--- a/Xi/ungrdevb.c
+++ b/Xi/ungrdevb.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "dixgrabs.h"
@@ -107,22 +106,23 @@ ProcXUngrabDeviceButton(ClientPtr client)
REQUEST(xUngrabDeviceButtonReq);
REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
- dev = LookupDeviceIntRec(stuff->grabbed_device);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
+ if (rc != Success)
+ return rc;
if (dev->button == NULL)
return BadMatch;
if (stuff->modifier_device != UseXKeyboard) {
- mdev = LookupDeviceIntRec(stuff->modifier_device);
- if (mdev == NULL)
+ rc = dixLookupDevice(&mdev, stuff->modifier_device, client,
+ DixReadAccess);
+ if (rc != Success)
return BadDevice;
if (mdev->key == NULL)
return BadMatch;
} else
- mdev = (DeviceIntPtr) LookupKeyboardDevice();
+ mdev = inputInfo.keyboard;
- rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c
index e6307af01..521765ea3 100644
--- a/Xi/ungrdevk.c
+++ b/Xi/ungrdevk.c
@@ -60,7 +60,6 @@ SOFTWARE.
#include "windowstr.h" /* window structure */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
-#include "extinit.h" /* LookupDeviceIntRec */
#include "exglobals.h"
#include "dixgrabs.h"
@@ -107,22 +106,23 @@ ProcXUngrabDeviceKey(ClientPtr client)
REQUEST(xUngrabDeviceKeyReq);
REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
- dev = LookupDeviceIntRec(stuff->grabbed_device);
- if (dev == NULL)
- return BadDevice;
+ rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess);
+ if (rc != Success)
+ return rc;
if (dev->key == NULL)
return BadMatch;
if (stuff->modifier_device != UseXKeyboard) {
- mdev = LookupDeviceIntRec(stuff->modifier_device);
- if (mdev == NULL)
+ rc = dixLookupDevice(&mdev, stuff->modifier_device, client,
+ DixReadAccess);
+ if (rc != Success)
return BadDevice;
if (mdev->key == NULL)
return BadMatch;
} else
- mdev = (DeviceIntPtr) LookupKeyboardDevice();
+ mdev = inputInfo.keyboard;
- rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
+ rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
diff --git a/afb/afb.h b/afb/afb.h
index 769e4502f..6731d9557 100644
--- a/afb/afb.h
+++ b/afb/afb.h
@@ -55,11 +55,11 @@ SOFTWARE.
#include "gc.h"
#include "colormap.h"
#include "regionstr.h"
+#include "privates.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
@@ -731,20 +731,21 @@ typedef struct {
} afbPrivGC;
typedef afbPrivGC *afbPrivGCPtr;
-extern int afbGCPrivateIndex; /* index into GC private array */
-extern int afbWindowPrivateIndex; /* index into Window private array */
+extern DevPrivateKey afbScreenPrivateKey;
+extern DevPrivateKey afbGCPrivateKey;
+extern DevPrivateKey afbWindowPrivateKey;
#ifdef PIXMAP_PER_WINDOW
-extern int frameWindowPrivateIndex; /* index into Window private array */
+extern DevPrivateKey frameWindowPrivateKey;
#endif
#define afbGetGCPrivate(pGC) \
- ((afbPrivGC *)((pGC)->devPrivates[afbGCPrivateIndex].ptr))
+ ((afbPrivGC *)dixLookupPrivate(&(pGC)->devPrivates, afbGCPrivateKey))
/* Common macros for extracting drawing information */
#define afbGetTypedWidth(pDrawable,wtype)( \
(((pDrawable)->type == DRAWABLE_WINDOW) ? \
- (int)(((PixmapPtr)((pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr))->devKind) : \
+ (int)(((PixmapPtr)dixLookupPrivate(&(pDrawable)->pScreen->devPrivates, afbScreenPrivateKey)->devKind) : \
(int)(((PixmapPtr)pDrawable)->devKind)) / sizeof (wtype))
#define afbGetByteWidth(pDrawable) afbGetTypedWidth(pDrawable, unsigned char)
@@ -754,7 +755,7 @@ extern int frameWindowPrivateIndex; /* index into Window private array */
#define afbGetTypedWidthAndPointer(pDrawable, width, pointer, wtype, ptype) {\
PixmapPtr _pPix; \
if ((pDrawable)->type == DRAWABLE_WINDOW) \
- _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
+ _pPix = (PixmapPtr)dixLookupPrivate(&(pDrawable)->pScreen->devPrivates, afbScreenPrivateKey); \
else \
_pPix = (PixmapPtr)(pDrawable); \
(pointer) = (ptype *) _pPix->devPrivate.ptr; \
@@ -764,7 +765,7 @@ extern int frameWindowPrivateIndex; /* index into Window private array */
#define afbGetPixelWidthSizeDepthAndPointer(pDrawable, width, size, dep, pointer) {\
PixmapPtr _pPix; \
if ((pDrawable)->type == DRAWABLE_WINDOW) \
- _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
+ _pPix = (PixmapPtr)dixLookupPrivate(&(pDrawable)->pScreen->devPrivates, afbScreenPrivateKey); \
else \
_pPix = (PixmapPtr)(pDrawable); \
(pointer) = (PixelType *)_pPix->devPrivate.ptr; \
@@ -780,7 +781,7 @@ extern int frameWindowPrivateIndex; /* index into Window private array */
afbGetTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
#define afbGetWindowTypedWidthAndPointer(pWin, width, pointer, wtype, ptype) {\
- PixmapPtr _pPix = (PixmapPtr)(pWin)->drawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
+ PixmapPtr _pPix = (PixmapPtr)dixLookupPrivate(&(pWin)->drawable.pScreen->devPrivates, afbScreenPrivateKey); \
(pointer) = (ptype *) _pPix->devPrivate.ptr; \
(width) = ((int) _pPix->devKind) / sizeof (wtype); \
}
diff --git a/afb/afbfillarc.c b/afb/afbfillarc.c
index fa685ba9a..cfc3133ee 100644
--- a/afb/afbfillarc.c
+++ b/afb/afbfillarc.c
@@ -321,7 +321,8 @@ afbPolyFillArcSolid(register DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parc
RegionPtr cclip;
unsigned char *rrops;
- priv = (afbPrivGC *) pGC->devPrivates[afbGCPrivateIndex].ptr;
+ priv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
rrops = priv->rrops;
cclip = pGC->pCompositeClip;
for (arc = parcs, i = narcs; --i >= 0; arc++) {
diff --git a/afb/afbfillrct.c b/afb/afbfillrct.c
index 1600deab3..4dff9576f 100644
--- a/afb/afbfillrct.c
+++ b/afb/afbfillrct.c
@@ -93,7 +93,8 @@ afbPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *pre
unsigned char *rrops;
unsigned char *rropsOS;
- priv = (afbPrivGC *)pGC->devPrivates[afbGCPrivateIndex].ptr;
+ priv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
prgnClip = pGC->pCompositeClip;
rrops = priv->rrops;
rropsOS = priv->rropOS;
diff --git a/afb/afbfillsp.c b/afb/afbfillsp.c
index b00185922..16295067b 100644
--- a/afb/afbfillsp.c
+++ b/afb/afbfillsp.c
@@ -123,7 +123,8 @@ afbSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
pBase);
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
while (n--) {
addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
@@ -238,8 +239,8 @@ afbStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
tileHeight = pStipple->drawable.height;
psrc = (PixelType *)(pStipple->devPrivate.ptr);
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
-
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
while (n--) {
src = psrc[ppt->y % tileHeight];
addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
@@ -484,8 +485,8 @@ afbOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
tileHeight = pTile->drawable.height;
psrc = (PixelType *)(pTile->devPrivate.ptr);
rop = pGC->alu;
- rropsOS = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rropOS;
-
+ rropsOS = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rropOS;
switch(rop) {
case GXcopy:
while (n--) {
@@ -793,8 +794,8 @@ afbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
tileWidth = pTile->drawable.width;
tileHeight = pTile->drawable.height;
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
-
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->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,
diff --git a/afb/afbgc.c b/afb/afbgc.c
index 59c09e097..1d1fdc58b 100644
--- a/afb/afbgc.c
+++ b/afb/afbgc.c
@@ -154,7 +154,8 @@ afbCreateGC(pGC)
/* afb wants to translate before scan convesion */
pGC->miTranslate = 1;
- pPriv = (afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr);
+ pPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
afbReduceRop(pGC->alu, pGC->fgPixel, pGC->planemask, pGC->depth,
pPriv->rrops);
afbReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
@@ -295,8 +296,8 @@ afbValidateGC(pGC, changes, pDrawable)
(oldOrg.y != pGC->lastWinOrg.y);
- devPriv = ((afbPrivGCPtr)(pGC->devPrivates[afbGCPrivateIndex].ptr));
-
+ devPriv = (afbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
/*
if the client clip is different or moved OR
diff --git a/afb/afbimggblt.c b/afb/afbimggblt.c
index ca49ee3ba..36818ac50 100644
--- a/afb/afbimggblt.c
+++ b/afb/afbimggblt.c
@@ -145,8 +145,8 @@ afbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
register int nFirst;/* bits of glyph in current longword */
PixelType *pdstSave;
int oldFill;
- afbPrivGC *pPriv = (afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr);
-
+ afbPrivGC *pPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
xorg = pDrawable->x;
yorg = pDrawable->y;
afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
diff --git a/afb/afbline.c b/afb/afbline.c
index 9e2e4b9f4..d05675869 100644
--- a/afb/afbline.c
+++ b/afb/afbline.c
@@ -147,7 +147,8 @@ afbLineSS(pDrawable, pGC, mode, npt, pptInit)
RegionPtr cclip;
cclip = pGC->pCompositeClip;
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
pboxInit = REGION_RECTS(cclip);
nboxInit = REGION_NUM_RECTS(cclip);
@@ -487,7 +488,8 @@ afbLineSD(pDrawable, pGC, mode, npt, pptInit)
#endif
cclip = pGC->pCompositeClip;
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
pboxInit = REGION_RECTS(cclip);
nboxInit = REGION_NUM_RECTS(cclip);
diff --git a/afb/afbpixmap.c b/afb/afbpixmap.c
index c6196182d..ad591a1af 100644
--- a/afb/afbpixmap.c
+++ b/afb/afbpixmap.c
@@ -115,6 +115,7 @@ afbDestroyPixmap(pPixmap)
{
if(--pPixmap->refcnt)
return(TRUE);
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return(TRUE);
}
diff --git a/afb/afbply1rct.c b/afb/afbply1rct.c
index 86ec174f4..e9d4d5e09 100644
--- a/afb/afbply1rct.c
+++ b/afb/afbply1rct.c
@@ -100,8 +100,8 @@ afbFillPolygonSolid (pDrawable, pGC, shape, mode, count, ptsIn)
int depthDst;
register PixelType *pdst;
- devPriv = (afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr);
-
+ devPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
if (mode == CoordModePrevious || shape != Convex ||
REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
diff --git a/afb/afbplygblt.c b/afb/afbplygblt.c
index bcb08c7a6..d1de102d7 100644
--- a/afb/afbplygblt.c
+++ b/afb/afbplygblt.c
@@ -146,8 +146,8 @@ afbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
bbox.y1 = y - info.overallAscent;
bbox.y2 = y + info.overallDescent;
- rrops = ((afbPrivGCPtr) pGC->devPrivates[afbGCPrivateIndex].ptr)->rrops;
-
+ rrops = ((afbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
case rgnOUT:
break;
diff --git a/afb/afbpolypnt.c b/afb/afbpolypnt.c
index a9d96edfe..b8ea3ed3e 100644
--- a/afb/afbpolypnt.c
+++ b/afb/afbpolypnt.c
@@ -90,8 +90,8 @@ afbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
register unsigned char *rrops;
afbPrivGC *pGCPriv;
- pGCPriv = (afbPrivGC *) pGC->devPrivates[afbGCPrivateIndex].ptr;
-
+ pGCPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
pBaseSave);
diff --git a/afb/afbscrinit.c b/afb/afbscrinit.c
index f3a054268..cbabb894e 100644
--- a/afb/afbscrinit.c
+++ b/afb/afbscrinit.c
@@ -69,12 +69,10 @@ SOFTWARE.
#include "servermd.h"
#ifdef PIXMAP_PER_WINDOW
-int frameWindowPrivateIndex;
+DevPrivateKey frameWindowPrivateKey = &frameWindowPrivateKey;
#endif
-int afbGCPrivateIndex;
-int afbScreenPrivateIndex;
-
-static unsigned long afbGeneration = 0;
+DevPrivateKey afbGCPrivateKey = &afbGCPrivateKey;
+DevPrivateKey afbScreenPrivateKey = &afbScreenPrivateKey;
static Bool
afbCloseScreen(int index, ScreenPtr pScreen)
@@ -86,7 +84,7 @@ afbCloseScreen(int index, ScreenPtr pScreen)
xfree(depths[d].vids);
xfree(depths);
xfree(pScreen->visuals);
- xfree(pScreen->devPrivates[afbScreenPrivateIndex].ptr);
+ xfree(dixLookupPrivate(&pScreen->devPrivates, afbScreenPrivateKey));
return(TRUE);
}
@@ -97,7 +95,8 @@ afbCreateScreenResources(ScreenPtr pScreen)
pointer oldDevPrivate = pScreen->devPrivate;
- pScreen->devPrivate = pScreen->devPrivates[afbScreenPrivateIndex].ptr;
+ pScreen->devPrivate = dixLookupPrivate(&pScreen->devPrivates,
+ afbScreenPrivateKey);
retval = miCreateScreenResources(pScreen);
/* Modify screen's pixmap devKind value stored off devPrivate to
@@ -105,7 +104,8 @@ afbCreateScreenResources(ScreenPtr pScreen)
* 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;
+ dixSetPrivate(&pScreen->devPrivates, afbScreenPrivateKey,
+ pScreen->devPrivate);
pScreen->devPrivate = oldDevPrivate;
return(retval);
}
@@ -114,7 +114,8 @@ static PixmapPtr
afbGetWindowPixmap(WindowPtr pWin)
{
#ifdef PIXMAP_PER_WINDOW
- return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
+ return (PixmapPtr)dixLookupPrivate(&pWin->devPrivates,
+ frameWindowPrivateKey);
#else
ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -126,29 +127,21 @@ static void
afbSetWindowPixmap(WindowPtr pWin, PixmapPtr pPix)
{
#ifdef PIXMAP_PER_WINDOW
- pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
+ dixSetPrivate(&pWin->devPrivates, frameWindowPrivateKey, pPix);
#else
(* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
#endif
}
static Bool
-afbAllocatePrivates(ScreenPtr pScreen, int *pWinIndex, int *pGCIndex)
+afbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
{
- if (afbGeneration != serverGeneration) {
-#ifdef PIXMAP_PER_WINDOW
- frameWindowPrivateIndex = AllocateWindowPrivateIndex();
-#endif
- afbGCPrivateIndex = AllocateGCPrivateIndex();
- afbGeneration = serverGeneration;
- }
- if (pGCIndex)
- *pGCIndex = afbGCPrivateIndex;
+ if (pGCKey)
+ *pGCKey = afbGCPrivateKey;
- afbScreenPrivateIndex = AllocateScreenPrivateIndex();
pScreen->GetWindowPixmap = afbGetWindowPixmap;
pScreen->SetWindowPixmap = afbSetWindowPixmap;
- return(AllocateGCPrivate(pScreen, afbGCPrivateIndex, sizeof(afbPrivGC)));
+ return dixRequestPrivate(afbGCPrivateKey, sizeof(afbPrivGC));
}
/* dts * (inch/dot) * (25.4 mm / inch) = mm */
@@ -174,7 +167,7 @@ afbScreenInit(register ScreenPtr pScreen, pointer pbits, int xsize, int ysize, i
ErrorF("afbInitVisuals: FALSE\n");
return FALSE;
}
- if (!afbAllocatePrivates(pScreen,(int *)NULL, (int *)NULL)) {
+ if (!afbAllocatePrivates(pScreen, NULL)) {
ErrorF("afbAllocatePrivates: FALSE\n");
return FALSE;
}
@@ -217,7 +210,8 @@ afbScreenInit(register ScreenPtr pScreen, pointer pbits, int xsize, int ysize, i
pScreen->CloseScreen = afbCloseScreen;
pScreen->CreateScreenResources = afbCreateScreenResources;
- pScreen->devPrivates[afbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ dixSetPrivate(&pScreen->devPrivates, afbScreenPrivateKey,
+ pScreen->devPrivate);
pScreen->devPrivate = oldDevPrivate;
return TRUE;
diff --git a/afb/afbtegblt.c b/afb/afbtegblt.c
index ba889cb80..c89b23a5d 100644
--- a/afb/afbtegblt.c
+++ b/afb/afbtegblt.c
@@ -261,8 +261,8 @@ afbTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
ypos -= FONTASCENT(pfont);
- rrops = ((afbPrivGCPtr) pGC->devPrivates[afbGCPrivateIndex].ptr)->rropOS;
-
+ rrops = ((afbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rropOS;
bbox.x1 = xpos;
bbox.x2 = xpos + (widthGlyph * nglyph);
bbox.y1 = ypos;
diff --git a/afb/afbwindow.c b/afb/afbwindow.c
index 61641ee31..c0dee980d 100644
--- a/afb/afbwindow.c
+++ b/afb/afbwindow.c
@@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/X.h>
#include "scrnintstr.h"
#include "windowstr.h"
+#include "privates.h"
#include "afb.h"
#include "mistruct.h"
#include "regionstr.h"
diff --git a/afb/afbzerarc.c b/afb/afbzerarc.c
index 2cc30687f..e53488e02 100644
--- a/afb/afbzerarc.c
+++ b/afb/afbzerarc.c
@@ -96,8 +96,8 @@ afbZeroArcSS(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
register PixelType *paddr;
register unsigned char *rrops;
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
-
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
addrl);
do360 = miZeroArcSetup(arc, &info, TRUE);
diff --git a/cfb/cfb.h b/cfb/cfb.h
index 6e9001f3f..aece13341 100644
--- a/cfb/cfb.h
+++ b/cfb/cfb.h
@@ -37,6 +37,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "colormap.h"
#include "miscstruct.h"
#include "servermd.h"
+#include "privates.h"
#include "windowstr.h"
#include "mfb.h"
#undef PixelType
@@ -55,7 +56,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
pixmap.devKind = width_of_pixmap_in_bytes
*/
-extern int cfbGCPrivateIndex;
+extern DevPrivateKey cfbGCPrivateKey;
/* private field of GC */
typedef struct {
@@ -70,7 +71,7 @@ typedef struct {
typedef cfbPrivGC *cfbPrivGCPtr;
#define cfbGetGCPrivate(pGC) ((cfbPrivGCPtr)\
- (pGC)->devPrivates[cfbGCPrivateIndex].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, cfbGCPrivateKey))
#define cfbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
@@ -298,7 +299,7 @@ extern int cfb8SegmentSS1RectXor(
extern Bool cfbAllocatePrivates(
ScreenPtr /*pScreen*/,
- int * /*gc_index*/
+ DevPrivateKey * /*gc_key*/
);
/* cfbbitblt.c */
@@ -1193,7 +1194,7 @@ extern void cfbZeroPolyArcSS8Xor(
#define CFB_NEED_SCREEN_PRIVATE
-extern int cfbScreenPrivateIndex;
+extern DevPrivateKey cfbScreenPrivateKey;
#endif
#ifndef CFB_PROTOTYPES_ONLY
diff --git a/cfb/cfballpriv.c b/cfb/cfballpriv.c
index 858ff6061..3b58266c5 100644
--- a/cfb/cfballpriv.c
+++ b/cfb/cfballpriv.c
@@ -45,38 +45,26 @@ in this Software without prior written authorization from The Open Group.
#include "mibstore.h"
#if 1 || PSZ==8
-int cfbGCPrivateIndex = -1;
+DevPrivateKey cfbGCPrivateKey = &cfbGCPrivateKey;
#endif
#ifdef CFB_NEED_SCREEN_PRIVATE
-int cfbScreenPrivateIndex = -1;
-static unsigned long cfbGeneration = 0;
+DevPrivateKey cfbScreenPrivateKey = &cfbScreenPrivateKey;
#endif
Bool
-cfbAllocatePrivates(ScreenPtr pScreen, int *gc_index)
+cfbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *gc_key)
{
- if (!gc_index || *gc_index == -1)
+ if (!gc_key || !*gc_key)
{
- if (!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex))
+ if (!mfbAllocatePrivates(pScreen, &cfbGCPrivateKey))
return FALSE;
- if (gc_index)
- *gc_index = cfbGCPrivateIndex;
+ if (gc_key)
+ *gc_key = cfbGCPrivateKey;
}
else
{
- cfbGCPrivateIndex = *gc_index;
+ cfbGCPrivateKey = *gc_key;
}
- if (!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;
+ return dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC));
}
diff --git a/cfb/cfbmap.h b/cfb/cfbmap.h
index d6d447555..16e4afc3c 100644
--- a/cfb/cfbmap.h
+++ b/cfb/cfbmap.h
@@ -140,7 +140,7 @@ cfb can not hack PSZ yet
#define cfbFillSpanTileOddGeneral CFBNAME(FillSpanTileOddGeneral)
#define cfbFinishScreenInit CFBNAME(FinishScreenInit)
#define cfbGCFuncs CFBNAME(GCFuncs)
-#define cfbGCPrivateIndex CFBNAME(GCPrivateIndex)
+#define cfbGCPrivateKey CFBNAME(GCPrivateKey)
#define cfbGetImage CFBNAME(GetImage)
#define cfbGetScreenPixmap CFBNAME(GetScreenPixmap)
#define cfbGetSpans CFBNAME(GetSpans)
@@ -170,7 +170,7 @@ cfb can not hack PSZ yet
#define cfbRestoreAreas CFBNAME(RestoreAreas)
#define cfbSaveAreas CFBNAME(SaveAreas)
#define cfbScreenInit CFBNAME(ScreenInit)
-#define cfbScreenPrivateIndex CFBNAME(ScreenPrivateIndex)
+#define cfbScreenPrivateKey CFBNAME(ScreenPrivateKey)
#define cfbSegmentSD CFBNAME(SegmentSD)
#define cfbSegmentSS CFBNAME(SegmentSS)
#define cfbSetScanline CFBNAME(SetScanline)
@@ -194,7 +194,7 @@ cfb can not hack PSZ yet
#define cfbUnnaturalTileFS CFBNAME(UnnaturalTileFS)
#define cfbValidateGC CFBNAME(ValidateGC)
#define cfbVertS CFBNAME(VertS)
-#define cfbWindowPrivateIndex CFBNAME(WindowPrivateIndex)
+#define cfbWindowPrivateKey CFBNAME(WindowPrivateKey)
#define cfbXRotatePixmap CFBNAME(XRotatePixmap)
#define cfbYRotatePixmap CFBNAME(YRotatePixmap)
#define cfbZeroPolyArcSS8Copy CFBNAME(ZeroPolyArcSSCopy)
diff --git a/cfb/cfbpixmap.c b/cfb/cfbpixmap.c
index f5a9a41ef..1166f90b7 100644
--- a/cfb/cfbpixmap.c
+++ b/cfb/cfbpixmap.c
@@ -109,6 +109,7 @@ cfbDestroyPixmap(pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/cfb/cfbrrop.h b/cfb/cfbrrop.h
index eeb373a5e..e9ca881be 100644
--- a/cfb/cfbrrop.h
+++ b/cfb/cfbrrop.h
@@ -35,7 +35,8 @@ in this Software without prior written authorization from The Open Group.
#endif
#define RROP_FETCH_GC(gc) \
- RROP_FETCH_GCPRIV(((cfbPrivGCPtr)(gc)->devPrivates[cfbGCPrivateIndex].ptr))
+ RROP_FETCH_GCPRIV((cfbPrivGCPtr)dixLookupPrivate(&(gc)->devPrivates, \
+ cfbGCPrivateKey))
#ifndef RROP
#define RROP GXset
diff --git a/cfb/cfbscrinit.c b/cfb/cfbscrinit.c
index ddfb41e6b..6f9ba2e85 100644
--- a/cfb/cfbscrinit.c
+++ b/cfb/cfbscrinit.c
@@ -59,7 +59,7 @@ cfbCloseScreen (index, pScreen)
xfree (depths);
xfree (pScreen->visuals);
#ifdef CFB_NEED_SCREEN_PRIVATE
- xfree (pScreen->devPrivates[cfbScreenPrivateIndex].ptr);
+ xfree (dixLookupPrivate(&pScreen->devPrivates, cfbScreenPrivateKey));
#else
xfree (pScreen->devPrivate);
#endif
@@ -130,9 +130,11 @@ cfbCreateScreenResources(pScreen)
Bool retval;
pointer oldDevPrivate = pScreen->devPrivate;
- pScreen->devPrivate = pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
+ pScreen->devPrivate = dixLookupPrivate(&pScreen->devPrivates,
+ cfbScreenPrivateKey);
retval = miCreateScreenResources(pScreen);
- pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ dixSetPrivate(&pScreen->devPrivates, cfbScreenPrivateKey,
+ pScreen->devPrivate);
pScreen->devPrivate = oldDevPrivate;
return retval;
}
@@ -171,7 +173,8 @@ cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
pScreen->CloseScreen = cfbCloseScreen;
#ifdef CFB_NEED_SCREEN_PRIVATE
pScreen->CreateScreenResources = cfbCreateScreenResources;
- pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ dixSetPrivate(&pScreen->devPrivates, cfbScreenPrivateKey,
+ pScreen->devPrivate);
pScreen->devPrivate = oldDevPrivate;
#endif
pScreen->GetScreenPixmap = cfbGetScreenPixmap;
@@ -198,7 +201,8 @@ cfbGetScreenPixmap(pScreen)
ScreenPtr pScreen;
{
#ifdef CFB_NEED_SCREEN_PRIVATE
- return (PixmapPtr)pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
+ return (PixmapPtr)dixLookupPrivate(&pScreen->devPrivates,
+ cfbScreenPrivateKey);
#else
return (PixmapPtr)pScreen->devPrivate;
#endif
@@ -210,8 +214,8 @@ cfbSetScreenPixmap(pPix)
{
#ifdef CFB_NEED_SCREEN_PRIVATE
if (pPix)
- pPix->drawable.pScreen->devPrivates[cfbScreenPrivateIndex].ptr =
- (pointer)pPix;
+ dixSetPrivate(&pPix->drawable.pScreen->devPrivates,
+ cfbScreenPrivateKey, pPix);
#else
if (pPix)
pPix->drawable.pScreen->devPrivate = (pointer)pPix;
diff --git a/cfb/cfbunmap.h b/cfb/cfbunmap.h
index d15c23e30..db9889217 100644
--- a/cfb/cfbunmap.h
+++ b/cfb/cfbunmap.h
@@ -93,7 +93,7 @@
#undef cfbFillSpanTileOddGeneral
#undef cfbFinishScreenInit
#undef cfbGCFuncs
-#undef cfbGCPrivateIndex
+#undef cfbGCPrivateKey
#undef cfbGetImage
#undef cfbGetScreenPixmap
#undef cfbGetSpans
@@ -123,7 +123,7 @@
#undef cfbRestoreAreas
#undef cfbSaveAreas
#undef cfbScreenInit
-#undef cfbScreenPrivateIndex
+#undef cfbScreenPrivateKey
#undef cfbSegmentSD
#undef cfbSegmentSS
#undef cfbSetScanline
@@ -147,7 +147,7 @@
#undef cfbUnnaturalTileFS
#undef cfbValidateGC
#undef cfbVertS
-#undef cfbWindowPrivateIndex
+#undef cfbWindowPrivateKey
#undef cfbXRotatePixmap
#undef cfbYRotatePixmap
#undef cfbZeroPolyArcSS8Copy
diff --git a/cfb/cfbwindow.c b/cfb/cfbwindow.c
index 234501212..50728764e 100644
--- a/cfb/cfbwindow.c
+++ b/cfb/cfbwindow.c
@@ -64,8 +64,8 @@ cfbCreateWindow(WindowPtr pWin)
{
#ifdef PIXMAP_PER_WINDOW
/* Setup pointer to Screen pixmap */
- pWin->devPrivates[frameWindowPrivateIndex].ptr =
- (pointer) cfbGetScreenPixmap(pWin->drawable.pScreen);
+ dixSetPrivate(&pWin->devPrivates, frameWindowPrivateKey,
+ cfbGetScreenPixmap(pWin->drawable.pScreen));
#endif
return TRUE;
diff --git a/composite/compalloc.c b/composite/compalloc.c
index dd5faa021..0372b9bfa 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -137,7 +137,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
cw->oldy = COMP_ORIGIN_INVALID;
cw->damageRegistered = FALSE;
cw->damaged = FALSE;
- pWin->devPrivates[CompWindowPrivateIndex].ptr = cw;
+ dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
}
ccw->next = cw->clients;
cw->clients = ccw;
@@ -212,7 +212,7 @@ compFreeClientWindow (WindowPtr pWin, XID id)
REGION_UNINIT (pScreen, &cw->borderClip);
- pWin->devPrivates[CompWindowPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL);
xfree (cw);
}
else if (cw->update == CompositeRedirectAutomatic &&
@@ -297,7 +297,7 @@ compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
}
csw->update = CompositeRedirectAutomatic;
csw->clients = 0;
- pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = csw;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, csw);
}
/*
* Redirect all existing windows
@@ -312,7 +312,7 @@ compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
if (!csw->clients)
{
xfree (csw);
- pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, 0);
}
xfree (ccw);
return ret;
@@ -385,7 +385,7 @@ compFreeClientSubwindows (WindowPtr pWin, XID id)
*/
if (!csw->clients)
{
- pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, NULL);
xfree (csw);
}
}
diff --git a/composite/compext.c b/composite/compext.c
index ece51d099..2918556f8 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -45,12 +45,13 @@
#endif
#include "compint.h"
+#include "xace.h"
#define SERVER_COMPOSITE_MAJOR 0
#define SERVER_COMPOSITE_MINOR 4
static CARD8 CompositeReqCode;
-static int CompositeClientPrivateIndex;
+static DevPrivateKey CompositeClientPrivateKey = &CompositeClientPrivateKey;
RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType;
static RESTYPE CompositeClientOverlayType;
@@ -63,7 +64,8 @@ typedef struct _CompositeClient {
int minor_version;
} CompositeClientRec, *CompositeClientPtr;
-#define GetCompositeClient(pClient) ((CompositeClientPtr) (pClient)->devPrivates[CompositeClientPrivateIndex].ptr)
+#define GetCompositeClient(pClient) ((CompositeClientPtr) \
+ dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey))
static void
CompositeClientCallback (CallbackListPtr *list,
@@ -156,14 +158,16 @@ static int
ProcCompositeRedirectWindow (ClientPtr client)
{
WindowPtr pWin;
+ int rc;
REQUEST(xCompositeRedirectWindowReq);
REQUEST_SIZE_MATCH(xCompositeRedirectWindowReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixSetAttrAccess|DixManageAccess|DixBlendAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
return compRedirectWindow (client, pWin, stuff->update);
}
@@ -172,14 +176,16 @@ static int
ProcCompositeRedirectSubwindows (ClientPtr client)
{
WindowPtr pWin;
+ int rc;
REQUEST(xCompositeRedirectSubwindowsReq);
REQUEST_SIZE_MATCH(xCompositeRedirectSubwindowsReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixSetAttrAccess|DixManageAccess|DixBlendAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
return compRedirectSubwindows (client, pWin, stuff->update);
}
@@ -222,14 +228,16 @@ ProcCompositeCreateRegionFromBorderClip (ClientPtr client)
WindowPtr pWin;
CompWindowPtr cw;
RegionPtr pBorderClip, pRegion;
+ int rc;
REQUEST(xCompositeCreateRegionFromBorderClipReq);
REQUEST_SIZE_MATCH(xCompositeCreateRegionFromBorderClipReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
LEGAL_NEW_RESOURCE (stuff->region, client);
@@ -256,14 +264,16 @@ ProcCompositeNameWindowPixmap (ClientPtr client)
WindowPtr pWin;
CompWindowPtr cw;
PixmapPtr pPixmap;
+ int rc;
REQUEST(xCompositeNameWindowPixmapReq);
REQUEST_SIZE_MATCH(xCompositeNameWindowPixmapReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
if (!pWin->viewable)
@@ -428,13 +438,15 @@ ProcCompositeGetOverlayWindow (ClientPtr client)
ScreenPtr pScreen;
CompScreenPtr cs;
CompOverlayClientPtr pOc;
+ int rc;
REQUEST_SIZE_MATCH(xCompositeGetOverlayWindowReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW, client,
+ DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
pScreen = pWin->drawable.pScreen;
@@ -445,6 +457,12 @@ ProcCompositeGetOverlayWindow (ClientPtr client)
return BadAlloc;
}
}
+
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id,
+ RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
MapWindow(cs->pOverlayWin, serverClient);
/* Record that client is using this overlay window */
@@ -715,9 +733,8 @@ CompositeExtensionInit (void)
if (!CompositeClientOverlayType)
return;
- CompositeClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (CompositeClientPrivateIndex,
- sizeof (CompositeClientRec)))
+ if (!dixRequestPrivate(CompositeClientPrivateKey,
+ sizeof(CompositeClientRec)))
return;
if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))
return;
diff --git a/composite/compinit.c b/composite/compinit.c
index 5f09fe2a4..49b2044b0 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -46,10 +46,9 @@
#include "compint.h"
-int CompScreenPrivateIndex;
-int CompWindowPrivateIndex;
-int CompSubwindowsPrivateIndex;
-static int CompGeneration;
+DevPrivateKey CompScreenPrivateKey = &CompScreenPrivateKey;
+DevPrivateKey CompWindowPrivateKey = &CompWindowPrivateKey;
+DevPrivateKey CompSubwindowsPrivateKey = &CompSubwindowsPrivateKey;
static Bool
@@ -86,7 +85,7 @@ compCloseScreen (int index, ScreenPtr pScreen)
cs->pOverlayWin = NULL;
xfree (cs);
- pScreen->devPrivates[CompScreenPrivateIndex].ptr = 0;
+ dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, NULL);
ret = (*pScreen->CloseScreen) (index, pScreen);
return ret;
@@ -374,25 +373,6 @@ 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));
@@ -457,7 +437,7 @@ compScreenInit (ScreenPtr pScreen)
cs->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = compCloseScreen;
- pScreen->devPrivates[CompScreenPrivateIndex].ptr = (pointer) cs;
+ dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, cs);
RegisterRealChildHeadProc(CompositeRealChildHead);
diff --git a/composite/compint.h b/composite/compint.h
index 535e1a423..4b0fe0834 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -64,6 +64,7 @@
#include "globals.h"
#include "picturestr.h"
#include "extnsionst.h"
+#include "privates.h"
#include "mi.h"
#include "damage.h"
#include "damageextint.h"
@@ -158,13 +159,16 @@ typedef struct _CompScreen {
} CompScreenRec, *CompScreenPtr;
-extern int CompScreenPrivateIndex;
-extern int CompWindowPrivateIndex;
-extern int CompSubwindowsPrivateIndex;
+extern DevPrivateKey CompScreenPrivateKey;
+extern DevPrivateKey CompWindowPrivateKey;
+extern DevPrivateKey CompSubwindowsPrivateKey;
-#define GetCompScreen(s) ((CompScreenPtr) ((s)->devPrivates[CompScreenPrivateIndex].ptr))
-#define GetCompWindow(w) ((CompWindowPtr) ((w)->devPrivates[CompWindowPrivateIndex].ptr))
-#define GetCompSubwindows(w) ((CompSubwindowsPtr) ((w)->devPrivates[CompSubwindowsPrivateIndex].ptr))
+#define GetCompScreen(s) ((CompScreenPtr) \
+ dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))
+#define GetCompWindow(w) ((CompWindowPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey))
+#define GetCompSubwindows(w) ((CompSubwindowsPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey))
extern RESTYPE CompositeClientWindowType;
extern RESTYPE CompositeClientSubwindowsType;
diff --git a/config/dbus.c b/config/dbus.c
index 6fe061815..f6ac4c11c 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -213,7 +213,7 @@ remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
MALFORMED_MESSAGE_ERROR();
}
- dev = LookupDeviceIntRec(deviceid);
+ dixLookupDevice(&dev, deviceid, serverClient, DixUnknownAccess);
if (!dev) {
DebugF("[config/dbus] bogus device id %d given\n", deviceid);
ret = BadMatch;
diff --git a/configure.ac b/configure.ac
index b56c11583..8dae13fd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,13 +97,6 @@ if test "x$WDTRACE" != "xno" ; then
fi
AM_CONDITIONAL(XSERVER_DTRACE, [test "x$WDTRACE" != "xno"])
-# DTrace support uses XErrorDB to get request names
-AC_ARG_WITH(xerrordb,
- AS_HELP_STRING([--with-xerrordb=PATH], [Path to XErrorDB file (default: ${datadir}/X11/XErrorDB)]),
- [ XERRORDB_PATH="$withval" ],
- [ XERRORDB_PATH="${datadir}/X11/XErrorDB" ])
-AC_DEFINE_DIR(XERRORDB_PATH, XERRORDB_PATH, [Path to XErrorDB file])
-
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
@@ -475,9 +468,10 @@ AC_ARG_WITH(xkb-path, AS_HELP_STRING([--with-xkb-path=PATH], [Path to XK
AC_ARG_WITH(xkb-output, AS_HELP_STRING([--with-xkb-output=PATH], [Path to XKB output dir (default: ${datadir}/X11/xkb/compiled)]),
[ XKBOUTPUT="$withval" ],
[ XKBOUTPUT="compiled" ])
-AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH], [Path to server config (default: ${libdir}/xserver)]),
+AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH],
+ [Directory where ancillary server config files are installed (default: ${libdir}/xorg)]),
[ SERVERCONFIG="$withval" ],
- [ SERVERCONFIG="${libdir}/xserver" ])
+ [ SERVERCONFIG="${libdir}/xorg" ])
APPLE_APPLICATIONS_DIR="/Applications/Utilities"
AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: /Applications/Utilities)]),
[ APPLE_APPLICATIONS_DIR="${withval}" ].
@@ -519,6 +513,7 @@ AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with
[GLX_USE_TLS=no])
dnl Extensions.
+AC_ARG_ENABLE(registry, AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
AC_ARG_ENABLE(composite, AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
AC_ARG_ENABLE(mitshm, AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
AC_ARG_ENABLE(xres, AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
@@ -536,8 +531,9 @@ AC_ARG_ENABLE(xinerama, AS_HELP_STRING([--disable-xinerama], [Build Xinera
AC_ARG_ENABLE(xf86vidmode, AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
AC_ARG_ENABLE(xf86misc, AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: auto)]), [XF86MISC=$enableval], [XF86MISC=auto])
AC_ARG_ENABLE(xace, AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
-AC_ARG_ENABLE(xcsecurity, AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: enabled)]), [XCSECURITY=$enableval], [XCSECURITY=$XACE])
-AC_ARG_ENABLE(appgroup, AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: enabled)]), [APPGROUP=$enableval], [APPGROUP=$XCSECURITY])
+AC_ARG_ENABLE(xselinux, AS_HELP_STRING([--disable-xselinux], [Build SELinux extension (default: disabled)]), [XSELINUX=$enableval], [XSELINUX=no])
+AC_ARG_ENABLE(xcsecurity, AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: disabled)]), [XCSECURITY=$enableval], [XCSECURITY=no])
+AC_ARG_ENABLE(appgroup, AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: disabled)]), [APPGROUP=$enableval], [APPGROUP=$XCSECURITY])
AC_ARG_ENABLE(xcalibrate, AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
AC_ARG_ENABLE(tslib, AS_HELP_STRING([--enable-tslib], [Build kdrive tslib touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no])
AC_ARG_ENABLE(xevie, AS_HELP_STRING([--disable-xevie], [Build XEvIE extension (default: enabled)]), [XEVIE=$enableval], [XEVIE=yes])
@@ -759,6 +755,10 @@ if test "x$XVMC" = xyes; then
AC_DEFINE(XvMCExtension, 1, [Build XvMC extension])
fi
+AM_CONDITIONAL(XREGISTRY, [test "x$XREGISTRY" = xyes])
+if test "x$XREGISTRY" = xyes; then
+ AC_DEFINE(XREGISTRY, 1, [Build registry module])
+fi
AM_CONDITIONAL(COMPOSITE, [test "x$COMPOSITE" = xyes])
if test "x$COMPOSITE" = xyes; then
@@ -861,6 +861,19 @@ if test "x$XACE" = xyes; then
AC_DEFINE(XACE, 1, [Build X-ACE extension])
fi
+AM_CONDITIONAL(XSELINUX, [test "x$XSELINUX" = xyes])
+if test "x$XSELINUX" = xyes; then
+ if test "x$XACE" != xyes; then
+ AC_MSG_ERROR([cannot build SELinux extension without X-ACE])
+ fi
+ AC_CHECK_HEADERS([selinux/selinux.h selinux/avc.h], [], AC_MSG_ERROR([SELinux include files not found]))
+ AC_CHECK_LIB(selinux, avc_init, [], AC_MSG_ERROR([SELinux library not found]))
+ AC_CHECK_HEADERS([libaudit.h], [], AC_MSG_ERROR([SELinux extension requires audit system headers]))
+ AC_CHECK_LIB(audit, audit_open, [], AC_MSG_ERROR([SELinux extension requires audit system library]))
+ AC_DEFINE(XSELINUX, 1, [Build SELinux extension])
+ SELINUX_LIB="-lselinux -laudit"
+fi
+
AM_CONDITIONAL(XCSECURITY, [test "x$XCSECURITY" = xyes])
if test "x$XCSECURITY" = xyes; then
if test "x$XACE" != xyes; then
@@ -1023,7 +1036,7 @@ fi
AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path])
-AC_DEFINE_DIR(SERVERCONFIGdir, SERVERCONFIG, [Server config path])
+AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path])
AC_DEFINE_DIR(BASE_FONT_PATH, FONTDIR, [Default base font path])
AC_DEFINE_DIR(DRI_DRIVER_PATH, DRI_DRIVER_PATH, [Default DRI driver path])
AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_NAME"], [Vendor name])
@@ -1062,7 +1075,6 @@ AC_DEFINE(XTEST, 1, [Support XTest extension])
AC_DEFINE(XSYNC, 1, [Support XSync extension])
AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
AC_DEFINE(BIGREQS, 1, [Support BigRequests extension])
-AC_DEFINE(PIXPRIV, 1, [Support pixmap privates])
if test "x$WDTRACE" != "xno" ; then
DIX_LIB='$(top_builddir)/dix/dix.O'
@@ -1282,7 +1294,7 @@ if test "x$XORG" = xyes -o "x$XGL" = xyes; then
XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
- XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB"
+ XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $SELINUX_LIB"
PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS"
diff --git a/damageext/damageext.c b/damageext/damageext.c
index e1724ecc7..517c72dac 100755
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -29,7 +29,7 @@
static unsigned char DamageReqCode;
static int DamageEventBase;
static int DamageErrorBase;
-static int DamageClientPrivateIndex;
+static DevPrivateKey DamageClientPrivateKey = &DamageClientPrivateKey;
static RESTYPE DamageExtType;
static RESTYPE DamageExtWinType;
@@ -185,7 +185,7 @@ ProcDamageCreate (ClientPtr client)
REQUEST_SIZE_MATCH(xDamageCreateReq);
LEGAL_NEW_RESOURCE(stuff->damage, client);
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixGetAttrAccess|DixReadAccess);
if (rc != Success)
return rc;
@@ -295,7 +295,7 @@ ProcDamageAdd (ClientPtr client)
REQUEST_SIZE_MATCH(xDamageAddReq);
VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixWriteAccess);
if (rc != Success)
return rc;
@@ -511,9 +511,7 @@ DamageExtensionInit(void)
if (!DamageExtWinType)
return;
- DamageClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (DamageClientPrivateIndex,
- sizeof (DamageClientRec)))
+ if (!dixRequestPrivate(DamageClientPrivateKey, sizeof (DamageClientRec)))
return;
if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0))
return;
diff --git a/damageext/damageextint.h b/damageext/damageextint.h
index dfafc9319..e06f28c4e 100644
--- a/damageext/damageextint.h
+++ b/damageext/damageextint.h
@@ -48,7 +48,7 @@ typedef struct _DamageClient {
int critical;
} DamageClientRec, *DamageClientPtr;
-#define GetDamageClient(pClient) ((DamageClientPtr) (pClient)->devPrivates[DamageClientPrivateIndex].ptr)
+#define GetDamageClient(pClient) ((DamageClientPtr)dixLookupPrivate(&(pClient)->devPrivates, DamageClientPrivateKey))
typedef struct _DamageExt {
DamagePtr pDamage;
diff --git a/dbe/dbe.c b/dbe/dbe.c
index cded2bd10..8175a352f 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -54,23 +54,21 @@
#define NEED_DBE_PROTOCOL
#include "dbestruct.h"
#include "midbe.h"
+#include "xace.h"
/* GLOBALS */
/* Per-screen initialization functions [init'ed by DbeRegisterFunction()] */
-static Bool (* DbeInitFunct[MAXSCREENS])(); /* pScreen, pDbeScreenPriv */
+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;
+static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKey;
+static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKey;
/* 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;
@@ -115,126 +113,6 @@ DbeRegisterFunction(ScreenPtr pScreen, Bool (*funct) (/* ??? */))
/******************************************************************************
*
- * 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(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: 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(void)
-{
- 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(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:
@@ -249,9 +127,6 @@ DbeStubScreen(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
@@ -359,7 +234,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
/* The window must be valid. */
- status = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+ status = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
if (status != Success)
return status;
@@ -419,11 +294,10 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
* Allocate a window priv.
*/
- if (!(pDbeWindowPriv =
- (*pDbeScreenPriv->AllocWinPriv)(pWin->drawable.pScreen)))
- {
+ pDbeWindowPriv = (DbeWindowPrivPtr)xalloc(sizeof(DbeWindowPrivRec));
+ if (!pDbeWindowPriv)
return(BadAlloc);
- }
+ bzero(pDbeWindowPriv, sizeof(DbeWindowPrivRec));
/* Make the window priv a DBE window priv resource. */
if (!AddResource(stuff->buffer, dbeWindowPrivResType,
@@ -454,7 +328,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
/* Actually connect the window priv to the window. */
- pWin->devPrivates[dbeWindowPrivIndex].ptr = (pointer)pDbeWindowPriv;
+ dixSetPrivate(&pWin->devPrivates, dbeWindowPrivKey, pDbeWindowPriv);
} /* if -- There is no buffer associated with the window. */
@@ -847,7 +721,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
for (i = 0; i < stuff->n; i++)
{
rc = dixLookupDrawable(pDrawables+i, drawables[i], client, 0,
- DixReadAccess);
+ DixGetAttrAccess);
if (rc != Success) {
Xfree(pDrawables);
return rc;
@@ -875,7 +749,9 @@ ProcDbeGetVisualInfo(ClientPtr client)
pDrawables[i]->pScreen;
pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
- if (!(*pDbeScreenPriv->GetVisualInfo)(pScreen, &pScrVisInfo[i]))
+ rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess);
+ if ((rc != Success) ||
+ !(*pDbeScreenPriv->GetVisualInfo)(pScreen, &pScrVisInfo[i]))
{
/* We failed to alloc pScrVisInfo[i].visinfo. */
@@ -891,7 +767,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
Xfree(pDrawables);
}
- return(BadAlloc);
+ return (rc == Success) ? BadAlloc : rc;
}
/* Account for n, number of xDbeVisInfo items in list. */
@@ -1004,7 +880,7 @@ ProcDbeGetBackBufferAttributes(ClientPtr client)
REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
if (!(pDbeWindowPriv = (DbeWindowPrivPtr)SecurityLookupIDByType(client,
- stuff->buffer, dbeWindowPrivResType, DixReadAccess)))
+ stuff->buffer, dbeWindowPrivResType, DixGetAttrAccess)))
{
rep.attributes = None;
}
@@ -1572,10 +1448,11 @@ DbeWindowPrivDelete(pointer pDbeWinPriv, XID id)
if (pDbeWindowPriv->nBufferIDs == 0)
{
/* Reset the DBE window priv pointer. */
- pDbeWindowPriv->pWindow->devPrivates[dbeWindowPrivIndex].ptr =
- (pointer)NULL;
+ dixSetPrivate(&pDbeWindowPriv->pWindow->devPrivates, dbeWindowPrivKey,
+ NULL);
/* We are done with the window priv. */
+ dixFreePrivates(pDbeWindowPriv->devPrivates);
xfree(pDbeWindowPriv);
}
@@ -1602,12 +1479,6 @@ DbeResetProc(ExtensionEntry *extEntry)
ScreenPtr pScreen;
DbeScreenPrivPtr pDbeScreenPriv;
-
- if (dbeScreenPrivIndex < 0)
- {
- return;
- }
-
for (i = 0; i < screenInfo.numScreens; i++)
{
pScreen = screenInfo.screens[i];
@@ -1621,11 +1492,7 @@ DbeResetProc(ExtensionEntry *extEntry)
if (pDbeScreenPriv->ResetProc)
(*pDbeScreenPriv->ResetProc)(pScreen);
- if (pDbeScreenPriv->winPrivPrivSizes)
- {
- xfree(pDbeScreenPriv->winPrivPrivSizes);
- }
-
+ dixFreePrivates(pDbeScreenPriv->devPrivates);
xfree(pDbeScreenPriv);
}
}
@@ -1746,26 +1613,14 @@ DbeExtensionInit(void)
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;
+ CreateNewResourceType(DbeDrawableDelete) | RC_DRAWABLE;
dbeWindowPrivResType =
CreateNewResourceType(DbeWindowPrivDelete);
+ if (!dixRegisterPrivateOffset(dbeDrawableResType,
+ offsetof(PixmapRec, devPrivates)))
+ return;
for (i = 0; i < screenInfo.numScreens; i++)
{
@@ -1775,8 +1630,7 @@ DbeExtensionInit(void)
pScreen = screenInfo.screens[i];
- if (!AllocateWindowPrivate(pScreen, dbeWindowPrivIndex, 0) ||
- !(pDbeScreenPriv =
+ if (!(pDbeScreenPriv =
(DbeScreenPrivPtr)Xcalloc(sizeof(DbeScreenPrivRec))))
{
/* If we can not alloc a window or screen private,
@@ -1785,28 +1639,23 @@ DbeExtensionInit(void)
for (j = 0; j < i; j++)
{
- xfree(screenInfo.screens[j]->devPrivates[dbeScreenPrivIndex].ptr);
- screenInfo.screens[j]->devPrivates[dbeScreenPrivIndex].ptr = NULL;
+ xfree(dixLookupPrivate(&screenInfo.screens[j]->devPrivates,
+ dbeScreenPrivKey));
+ dixSetPrivate(&screenInfo.screens[j]->devPrivates,
+ dbeScreenPrivKey, 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);
+ dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv);
/* Copy the resource types */
pDbeScreenPriv->dbeDrawableResType = dbeDrawableResType;
pDbeScreenPriv->dbeWindowPrivResType = dbeWindowPrivResType;
/* Copy the private indices */
- pDbeScreenPriv->dbeScreenPrivIndex = dbeScreenPrivIndex;
- pDbeScreenPriv->dbeWindowPrivIndex = dbeWindowPrivIndex;
+ pDbeScreenPriv->dbeScreenPrivKey = dbeScreenPrivKey;
+ pDbeScreenPriv->dbeWindowPrivKey = dbeWindowPrivKey;
if(DbeInitFunct[i])
{
@@ -1814,9 +1663,6 @@ DbeExtensionInit(void)
/* Setup DIX. */
pDbeScreenPriv->SetupBackgroundPainter = DbeSetupBackgroundPainter;
- pDbeScreenPriv->AllocWinPriv = DbeAllocWinPriv;
- pDbeScreenPriv->AllocWinPrivPrivIndex = DbeAllocWinPrivPrivIndex;
- pDbeScreenPriv->AllocWinPrivPriv = DbeAllocWinPrivPriv;
/* Setup DDX. */
ddxInitSuccess = (*DbeInitFunct[i])(pScreen, pDbeScreenPriv);
@@ -1848,9 +1694,6 @@ DbeExtensionInit(void)
#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);
@@ -1889,8 +1732,9 @@ DbeExtensionInit(void)
for (i = 0; i < screenInfo.numScreens; i++)
{
- xfree(screenInfo.screens[i]->devPrivates[dbeScreenPrivIndex].ptr);
- pScreen->devPrivates[dbeScreenPrivIndex].ptr = NULL;
+ xfree(dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
+ dbeScreenPrivKey));
+ dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, NULL);
}
return;
}
diff --git a/dbe/dbestruct.h b/dbe/dbestruct.h
index 90f13428a..7d5a115ad 100644
--- a/dbe/dbestruct.h
+++ b/dbe/dbestruct.h
@@ -39,14 +39,13 @@
#define NEED_DBE_PROTOCOL
#include <X11/extensions/Xdbeproto.h>
#include "windowstr.h"
+#include "privates.h"
/* DEFINES */
-#define DBE_SCREEN_PRIV(pScreen) \
- ((dbeScreenPrivIndex < 0) ? \
- NULL : \
- ((DbeScreenPrivPtr)((pScreen)->devPrivates[dbeScreenPrivIndex].ptr)))
+#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey))
#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
DBE_SCREEN_PRIV((pDrawable)->pScreen)
@@ -63,10 +62,8 @@
#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)))
+#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey))
/* Initial size of the buffer ID array in the window priv. */
#define DBE_INIT_MAX_IDS 2
@@ -142,7 +139,7 @@ typedef struct _DbeWindowPrivRec
/* Device-specific private information.
*/
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
} DbeWindowPrivRec, *DbeWindowPrivPtr;
@@ -155,18 +152,13 @@ typedef struct _DbeWindowPrivRec
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;
+ DevPrivateKey dbeScreenPrivKey;
+ DevPrivateKey dbeWindowPrivKey;
/* Wrapped functions
* It is the responsibilty of the DDX layer to wrap PositionWindow().
@@ -180,17 +172,6 @@ typedef struct _DbeScreenPrivRec
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)(
@@ -223,7 +204,7 @@ typedef struct _DbeScreenPrivRec
/* Device-specific private information.
*/
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
} DbeScreenPrivRec, *DbeScreenPrivPtr;
diff --git a/dbe/midbe.c b/dbe/midbe.c
index ac7ee62d4..c02e591d0 100644
--- a/dbe/midbe.c
+++ b/dbe/midbe.c
@@ -56,15 +56,15 @@
#include "gcstruct.h"
#include "inputstr.h"
#include "midbe.h"
+#include "xace.h"
#include <stdio.h>
-static int miDbePrivPrivGeneration = 0;
-static int miDbeWindowPrivPrivIndex = -1;
+static DevPrivateKey miDbeWindowPrivPrivKey = &miDbeWindowPrivPrivKey;
static RESTYPE dbeDrawableResType;
static RESTYPE dbeWindowPrivResType;
-static int dbeScreenPrivIndex = -1;
-static int dbeWindowPrivIndex = -1;
+static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKey;
+static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKey;
/******************************************************************************
@@ -154,6 +154,7 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
DbeScreenPrivPtr pDbeScreenPriv;
GCPtr pGC;
xRectangle clearRect;
+ int rc;
pScreen = pWin->drawable.pScreen;
@@ -192,20 +193,24 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
return(BadAlloc);
}
+ /* Security creation/labeling check. */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, serverClient, bufId,
+ dbeDrawableResType, pDbeWindowPrivPriv->pBackBuffer,
+ RT_WINDOW, pWin, DixCreateAccess);
/* Make the back pixmap a DBE drawable resource. */
- if (!AddResource(bufId, dbeDrawableResType,
- (pointer)pDbeWindowPrivPriv->pBackBuffer))
+ if (rc != Success || !AddResource(bufId, dbeDrawableResType,
+ pDbeWindowPrivPriv->pBackBuffer))
{
/* free the buffer and the drawable resource */
FreeResource(bufId, RT_NONE);
- return(BadAlloc);
+ return (rc == Success) ? BadAlloc : rc;
}
/* Attach the priv priv to the priv. */
- pDbeWindowPriv->devPrivates[miDbeWindowPrivPrivIndex].ptr =
- (pointer)pDbeWindowPrivPriv;
+ dixSetPrivate(&pDbeWindowPriv->devPrivates, miDbeWindowPrivPrivKey,
+ pDbeWindowPrivPriv);
/* Clear the back buffer. */
@@ -778,30 +783,12 @@ miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
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.
- **********************************************************************
- */
+ dbeScreenPrivKey = pDbeScreenPriv->dbeScreenPrivKey;
+ dbeWindowPrivKey = pDbeScreenPriv->dbeWindowPrivKey;
- miDbeWindowPrivPrivIndex = (*pDbeScreenPriv->AllocWinPrivPrivIndex)();
-
- /* Make sure we only do this code once. */
- miDbePrivPrivGeneration = serverGeneration;
-
- } /* if -- Reset priv privs. */
-
- if (!(*pDbeScreenPriv->AllocWinPrivPriv)(pScreen,
- miDbeWindowPrivPrivIndex, sizeof(MiDbeWindowPrivPrivRec)))
- {
+ if (!dixRequestPrivate(miDbeWindowPrivPrivKey,
+ sizeof(MiDbeWindowPrivPrivRec)))
return(FALSE);
- }
/* Wrap functions. */
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
diff --git a/dbe/midbestr.h b/dbe/midbestr.h
index 1ad0104aa..ae9f206fc 100644
--- a/dbe/midbestr.h
+++ b/dbe/midbestr.h
@@ -42,19 +42,15 @@
/* DEFINES */
#define MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv) \
- (((miDbeWindowPrivPrivIndex < 0) || (!pDbeWindowPriv)) ? \
- NULL : \
- ((MiDbeWindowPrivPrivPtr) \
- ((pDbeWindowPriv)->devPrivates[miDbeWindowPrivPrivIndex].ptr)))
+ (!(pDbeWindowPriv) ? NULL : (MiDbeWindowPrivPrivPtr) \
+ dixLookupPrivate(&(pDbeWindowPriv)->devPrivates, miDbeWindowPrivPrivKey))
#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)))
+ (!(pDbeScreenPriv) ? NULL : (MiDbeScreenPrivPrivPtr) \
+ dixLookupPrivate(&(pDbeScreenPriv)->devPrivates, miDbeScreenPrivPrivKey))
/* TYPEDEFS */
diff --git a/dix/Makefile.am b/dix/Makefile.am
index 28c2d8b6e..2cf90142f 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -8,6 +8,7 @@ libdix_la_SOURCES = \
atom.c \
colormap.c \
cursor.c \
+ deprecated.c \
devices.c \
dispatch.c \
dispatch.h \
@@ -26,6 +27,7 @@ libdix_la_SOURCES = \
pixmap.c \
privates.c \
property.c \
+ registry.c \
resource.c \
swaprep.c \
swapreq.c \
@@ -40,6 +42,10 @@ INCLUDES = -I$(top_srcdir)/Xprint
EXTRA_DIST = buildatoms BuiltInAtoms CHANGES Xserver.d Xserver-dtrace.h.in
+# Install list of protocol names
+miscconfigdir = $(SERVER_MISC_CONFIG_PATH)
+dist_miscconfig_DATA = protocol.txt
+
if XSERVER_DTRACE
# Generate dtrace header file for C sources to include
BUILT_SOURCES = Xserver-dtrace.h
diff --git a/dix/colormap.c b/dix/colormap.c
index b27b8bc67..c4c8c8bfe 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -63,9 +63,10 @@ SOFTWARE.
#include "scrnintstr.h"
#include "resource.h"
#include "windowstr.h"
+#include "privates.h"
+#include "xace.h"
extern XID clientErrorValue;
-extern int colormapPrivateCount;
static Pixel FindBestPixel(
EntryPtr /*pentFirst*/,
@@ -386,31 +387,25 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
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->devPrivates = NULL;
pmap->flags |= BeingCreated;
+ if (!AddResource(mid, RT_COLORMAP, (pointer)pmap))
+ return (BadAlloc);
- /*
- * Allocate the array of devPrivate's for this colormap.
+ /*
+ * Security creation/labeling check
*/
-
- if (colormapPrivateCount == 0)
- pmap->devPrivates = NULL;
- else
- {
- pmap->devPrivates = (DevUnion *) xcalloc (
- sizeof(DevUnion), colormapPrivateCount);
- if (!pmap->devPrivates)
- {
- FreeResource (mid, RT_NONE);
- return BadAlloc;
- }
+ i = XaceHook(XACE_RESOURCE_ACCESS, clients[client], mid, RT_COLORMAP,
+ pmap, RT_NONE, NULL, DixCreateAccess);
+ if (i != Success) {
+ FreeResource(mid, RT_NONE);
+ return i;
}
+ /* 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 */
if (!(*pScreen->CreateColormap)(pmap))
{
FreeResource (mid, RT_NONE);
@@ -474,9 +469,7 @@ FreeColormap (pointer value, XID mid)
}
}
- if (pmap->devPrivates)
- xfree(pmap->devPrivates);
-
+ dixFreePrivates(pmap->devPrivates);
xfree(pmap);
return(Success);
}
diff --git a/dix/cursor.c b/dix/cursor.c
index d903124c4..0ddf9d791 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -59,6 +59,7 @@ SOFTWARE.
#include "cursorstr.h"
#include "dixfontstr.h"
#include "opaque.h"
+#include "xace.h"
typedef struct _GlyphShare {
FontPtr font;
@@ -98,6 +99,7 @@ FreeCursorBits(CursorBitsPtr bits)
CloseFont(this->font, (Font)0);
xfree(this);
}
+ dixFreePrivates(bits->devPrivates);
xfree(bits);
}
}
@@ -123,6 +125,7 @@ FreeCursor(pointer value, XID cid)
pscr = screenInfo.screens[nscr];
(void)( *pscr->UnrealizeCursor)( pscr, pCurs);
}
+ dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(pCurs->bits);
xfree( pCurs);
return(Success);
@@ -161,23 +164,25 @@ CheckForEmptyMask(CursorBitsPtr bits)
* \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)
+int
+AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
+ CARD32 *argb, CursorMetricPtr cm,
+ unsigned foreRed, unsigned foreGreen, unsigned foreBlue,
+ unsigned backRed, unsigned backGreen, unsigned backBlue,
+ CursorPtr *ppCurs, ClientPtr client, XID cid)
{
CursorBitsPtr bits;
CursorPtr pCurs;
- int nscr;
+ int rc, nscr;
ScreenPtr pscr;
+ *ppCurs = NULL;
pCurs = (CursorPtr)xalloc(sizeof(CursorRec) + sizeof(CursorBits));
if (!pCurs)
{
xfree(psrcbits);
xfree(pmaskbits);
- return (CursorPtr)NULL;
+ return BadAlloc;
}
bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec));
bits->source = psrcbits;
@@ -189,9 +194,9 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
bits->height = cm->height;
bits->xhot = cm->xhot;
bits->yhot = cm->yhot;
+ bits->devPrivates = NULL;
bits->refcnt = -1;
CheckForEmptyMask(bits);
-
pCurs->bits = bits;
pCurs->refcnt = 1;
#ifdef XFIXES
@@ -207,6 +212,19 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
pCurs->backGreen = backGreen;
pCurs->backBlue = backBlue;
+ pCurs->id = cid;
+ pCurs->devPrivates = NULL;
+
+ /* security creation/labeling check */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
+ pCurs, RT_NONE, NULL, DixCreateAccess);
+ if (rc != Success) {
+ dixFreePrivates(pCurs->devPrivates);
+ FreeCursorBits(bits);
+ xfree(pCurs);
+ return rc;
+ }
+
/*
* realize the cursor for every screen
*/
@@ -220,61 +238,46 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
pscr = screenInfo.screens[nscr];
( *pscr->UnrealizeCursor)( pscr, pCurs);
}
+ dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits);
xfree(pCurs);
- return (CursorPtr)NULL;
+ return BadAlloc;
}
}
- 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);
+ *ppCurs = pCurs;
+ return rc;
}
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)
+ CursorPtr *ppCurs, ClientPtr client, XID cid)
{
FontPtr sourcefont, maskfont;
unsigned char *srcbits;
unsigned char *mskbits;
CursorMetricRec cm;
- int res;
+ int rc;
CursorBitsPtr bits;
CursorPtr pCurs;
int nscr;
ScreenPtr pscr;
GlyphSharePtr pShare;
- sourcefont = (FontPtr) SecurityLookupIDByType(client, source, RT_FONT,
- DixReadAccess);
- maskfont = (FontPtr) SecurityLookupIDByType(client, mask, RT_FONT,
- DixReadAccess);
-
- if (!sourcefont)
+ rc = dixLookupResource((pointer *)&sourcefont, source, RT_FONT, client,
+ DixUseAccess);
+ if (rc != Success)
{
client->errorValue = source;
- return(BadFont);
+ return (rc == BadValue) ? BadFont : rc;
}
- if (!maskfont && (mask != None))
+ rc = dixLookupResource((pointer *)&maskfont, mask, RT_FONT, client,
+ DixUseAccess);
+ if (rc != Success && mask != None)
{
client->errorValue = mask;
- return(BadFont);
+ return (rc == BadValue) ? BadFont : rc;
}
if (sourcefont != maskfont)
pShare = (GlyphSharePtr)NULL;
@@ -322,13 +325,13 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
client->errorValue = maskChar;
return BadValue;
}
- if ((res = ServerBitsFromGlyph(maskfont, maskChar, &cm, &mskbits)) != 0)
- return res;
+ if ((rc = ServerBitsFromGlyph(maskfont, maskChar, &cm, &mskbits)))
+ return rc;
}
- if ((res = ServerBitsFromGlyph(sourcefont, sourceChar, &cm, &srcbits)) != 0)
+ if ((rc = ServerBitsFromGlyph(sourcefont, sourceChar, &cm, &srcbits)))
{
xfree(mskbits);
- return res;
+ return rc;
}
if (sourcefont != maskfont)
{
@@ -362,6 +365,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
bits->height = cm.height;
bits->xhot = cm.xhot;
bits->yhot = cm.yhot;
+ bits->devPrivates = NULL;
if (sourcefont != maskfont)
bits->refcnt = -1;
else
@@ -398,6 +402,19 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
pCurs->backGreen = backGreen;
pCurs->backBlue = backBlue;
+ pCurs->id = cid;
+ pCurs->devPrivates = NULL;
+
+ /* security creation/labeling check */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
+ pCurs, RT_NONE, NULL, DixCreateAccess);
+ if (rc != Success) {
+ dixFreePrivates(pCurs->devPrivates);
+ FreeCursorBits(bits);
+ xfree(pCurs);
+ return rc;
+ }
+
/*
* realize the cursor for every screen
*/
@@ -411,6 +428,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
pscr = screenInfo.screens[nscr];
( *pscr->UnrealizeCursor)( pscr, pCurs);
}
+ dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(pCurs->bits);
xfree(pCurs);
return BadAlloc;
@@ -447,7 +465,8 @@ CreateRootCursor(char *unused1, unsigned int unused2)
cm.xhot = 0;
cm.yhot = 0;
- curs = AllocCursor(NULL, NULL, &cm, 0, 0, 0, 0, 0, 0);
+ AllocARGBCursor(NULL, NULL, NULL, &cm, 0, 0, 0, 0, 0, 0,
+ &curs, serverClient, (XID)0);
if (curs == NullCursor)
return NullCursor;
@@ -461,8 +480,8 @@ CreateRootCursor(char *unused1, unsigned int unused2)
cursorfont = (FontPtr)LookupIDByType(fontID, RT_FONT);
if (!cursorfont)
return NullCursor;
- if (AllocGlyphCursor(fontID, 0, fontID, 1,
- 0, 0, 0, ~0, ~0, ~0, &curs, serverClient) != Success)
+ if (AllocGlyphCursor(fontID, 0, fontID, 1, 0, 0, 0, ~0, ~0, ~0,
+ &curs, serverClient, (XID)0) != Success)
return NullCursor;
#endif
diff --git a/dix/deprecated.c b/dix/deprecated.c
new file mode 100644
index 000000000..2bb81190c
--- /dev/null
+++ b/dix/deprecated.c
@@ -0,0 +1,162 @@
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dix.h"
+#include "misc.h"
+#include "dixstruct.h"
+
+/*
+ * These are deprecated compatibility functions and will be marked as such
+ * and removed soon!
+ *
+ * Please use the noted replacements instead.
+ */
+
+/* replaced by dixLookupWindow */
+_X_EXPORT WindowPtr
+SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode)
+{
+ WindowPtr pWin;
+ int i = dixLookupWindow(&pWin, id, client, access_mode);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupWindow()/SecurityLookupWindow() "
+ "are deprecated. Please convert your driver/module "
+ "to use dixLookupWindow().\n");
+ return (i == Success) ? pWin : NULL;
+}
+
+/* replaced by dixLookupWindow */
+_X_EXPORT WindowPtr
+LookupWindow(XID id, ClientPtr client)
+{
+ return SecurityLookupWindow(id, client, DixUnknownAccess);
+}
+
+/* replaced by dixLookupDrawable */
+_X_EXPORT pointer
+SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode)
+{
+ DrawablePtr pDraw;
+ int i = dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() "
+ "are deprecated. Please convert your driver/module "
+ "to use dixLookupDrawable().\n");
+ return (i == Success) ? pDraw : NULL;
+}
+
+/* replaced by dixLookupDrawable */
+_X_EXPORT pointer
+LookupDrawable(XID id, ClientPtr client)
+{
+ return SecurityLookupDrawable(id, client, DixUnknownAccess);
+}
+
+/* replaced by dixLookupClient */
+_X_EXPORT ClientPtr
+LookupClient(XID id, ClientPtr client)
+{
+ ClientPtr pClient;
+ int i = dixLookupClient(&pClient, id, client, DixUnknownAccess);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupClient() is deprecated. Please convert your "
+ "driver/module to use dixLookupClient().\n");
+ return (i == Success) ? pClient : NULL;
+}
+
+/* replaced by dixLookupResource */
+_X_EXPORT pointer
+SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype,
+ Mask access_mode)
+{
+ pointer retval;
+ int i = dixLookupResource(&retval, id, rtype, client, access_mode);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() "
+ "are deprecated. Please convert your driver/module "
+ "to use dixLookupResource().\n");
+ return (i == Success) ? retval : NULL;
+}
+
+/* replaced by dixLookupResource */
+_X_EXPORT pointer
+SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes,
+ Mask access_mode)
+{
+ pointer retval;
+ int i = dixLookupResource(&retval, id, classes, client, access_mode);
+ static int warn = 1;
+ if (warn > 0 && --warn)
+ ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() "
+ "are deprecated. Please convert your driver/module "
+ "to use dixLookupResource().\n");
+ return (i == Success) ? retval : NULL;
+}
+
+/* replaced by dixLookupResource */
+_X_EXPORT pointer
+LookupIDByType(XID id, RESTYPE rtype)
+{
+ return SecurityLookupIDByType(NullClient, id, rtype, DixUnknownAccess);
+}
+
+/* replaced by dixLookupResource */
+_X_EXPORT pointer
+LookupIDByClass(XID id, RESTYPE classes)
+{
+ return SecurityLookupIDByClass(NullClient, id, classes, DixUnknownAccess);
+}
+
+/* end deprecated functions */
diff --git a/dix/devices.c b/dix/devices.c
index 3855c2b8b..adf2fba45 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -69,6 +69,7 @@ SOFTWARE.
#ifdef XKB
#include <xkbsrv.h>
#endif
+#include "privates.h"
#include "xace.h"
#include "dispatch.h"
@@ -84,8 +85,7 @@ SOFTWARE.
* This file handles input device-related stuff.
*/
-int CoreDevicePrivatesIndex = 0;
-static int CoreDevicePrivatesGeneration = -1;
+DevPrivateKey CoreDevicePrivateKey = &CoreDevicePrivateKey;
/**
* Create a new input device and init it to sane values. The device is added
@@ -119,7 +119,6 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
dev->name = (char *)NULL;
dev->type = 0;
dev->id = devid;
- inputInfo.numDevices++;
dev->public.on = FALSE;
dev->public.processInputProc = (ProcessInputProc)NoopDDA;
dev->public.realInputProc = (ProcessInputProc)NoopDDA;
@@ -150,13 +149,21 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
dev->xkb_interest = NULL;
#endif
dev->config_info = NULL;
- dev->nPrivates = 0;
dev->devPrivates = NULL;
dev->unwrapProc = NULL;
dev->coreEvents = TRUE;
dev->inited = FALSE;
dev->enabled = FALSE;
+ /* security creation/labeling check
+ */
+ if (XaceHook(XACE_DEVICE_ACCESS, serverClient, dev, DixCreateAccess)) {
+ xfree(dev);
+ return NULL;
+ }
+
+ inputInfo.numDevices++;
+
for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next)
;
*prev = dev;
@@ -351,7 +358,7 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what)
break;
case DEVICE_CLOSE:
- pDev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
+ dixSetPrivate(&pDev->devPrivates, CoreDevicePrivateKey, NULL);
break;
default:
@@ -383,7 +390,7 @@ CorePointerProc(DeviceIntPtr pDev, int what)
break;
case DEVICE_CLOSE:
- pDev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
+ dixSetPrivate(&pDev->devPrivates, CoreDevicePrivateKey, NULL);
break;
default:
@@ -404,11 +411,6 @@ InitCoreDevices(void)
{
DeviceIntPtr dev;
- if (CoreDevicePrivatesGeneration != serverGeneration) {
- CoreDevicePrivatesIndex = AllocateDevicePrivateIndex();
- CoreDevicePrivatesGeneration = serverGeneration;
- }
-
if (!inputInfo.keyboard) {
dev = AddInputDevice(CoreKeyboardProc, TRUE);
if (!dev)
@@ -426,9 +428,6 @@ InitCoreDevices(void)
dev->ActivateGrab = ActivateKeyboardGrab;
dev->DeactivateGrab = DeactivateKeyboardGrab;
dev->coreEvents = FALSE;
- if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
- FatalError("Couldn't allocate keyboard devPrivates\n");
- dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
(void)ActivateDevice(dev);
inputInfo.keyboard = dev;
}
@@ -450,9 +449,6 @@ InitCoreDevices(void)
dev->ActivateGrab = ActivatePointerGrab;
dev->DeactivateGrab = DeactivatePointerGrab;
dev->coreEvents = FALSE;
- if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
- FatalError("Couldn't allocate pointer devPrivates\n");
- dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
(void)ActivateDevice(dev);
inputInfo.pointer = dev;
}
@@ -603,10 +599,8 @@ CloseDevice(DeviceIntPtr dev)
XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
#endif
- if (dev->devPrivates)
- xfree(dev->devPrivates);
-
xfree(dev->sync.event);
+ dixFreePrivates(dev->devPrivates);
xfree(dev);
}
@@ -720,32 +714,28 @@ RegisterKeyboardDevice(DeviceIntPtr device)
RegisterOtherDevice(device);
}
-_X_EXPORT DevicePtr
-LookupKeyboardDevice(void)
-{
- return inputInfo.keyboard ? &inputInfo.keyboard->public : NULL;
-}
-
-_X_EXPORT DevicePtr
-LookupPointerDevice(void)
-{
- return inputInfo.pointer ? &inputInfo.pointer->public : NULL;
-}
-
-DevicePtr
-LookupDevice(int id)
+int
+dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode)
{
DeviceIntPtr dev;
+ int rc;
+ *pDev = NULL;
for (dev=inputInfo.devices; dev; dev=dev->next) {
if (dev->id == (CARD8)id)
- return (DevicePtr)dev;
+ goto found;
}
for (dev=inputInfo.off_devices; dev; dev=dev->next) {
if (dev->id == (CARD8)id)
- return (DevicePtr)dev;
+ goto found;
}
- return NULL;
+ return BadDevice;
+
+found:
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
+ if (rc == Success)
+ *pDev = dev;
+ return rc;
}
void
@@ -1286,10 +1276,10 @@ AllModifierKeysAreUp(dev, map1, per1, map2, per2)
static int
DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
- int numKeyPerModifier)
+ int numKeyPerModifier, xSetModifierMappingReply *rep)
{
DeviceIntPtr pDev = NULL;
- int i = 0, inputMapLen = numKeyPerModifier * 8;
+ int rc, i = 0, inputMapLen = numKeyPerModifier * 8;
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
@@ -1304,8 +1294,9 @@ DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
}
}
- if (!XaceHook(XACE_DEVICE_ACCESS, client, pDev, TRUE))
- return BadAccess;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
/* None of the modifiers (old or new) may be down while we change
* the map. */
@@ -1315,7 +1306,8 @@ DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
!AllModifierKeysAreUp(pDev, inputMap, numKeyPerModifier,
pDev->key->modifierKeyMap,
pDev->key->maxKeysPerModifier)) {
- return MappingBusy;
+ rep->success = MappingBusy;
+ return Success;
}
}
}
@@ -1352,6 +1344,7 @@ DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
}
}
+ rep->success = Success;
return Success;
}
@@ -1360,8 +1353,8 @@ ProcSetModifierMapping(ClientPtr client)
{
xSetModifierMappingReply rep;
DeviceIntPtr dev;
+ int rc;
REQUEST(xSetModifierMappingReq);
-
REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
if (client->req_len != ((stuff->numKeyPerModifier << 1) +
@@ -1372,8 +1365,10 @@ ProcSetModifierMapping(ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
- rep.success = DoSetModifierMapping(client, (KeyCode *)&stuff[1],
- stuff->numKeyPerModifier);
+ rc = DoSetModifierMapping(client, (KeyCode *)&stuff[1],
+ stuff->numKeyPerModifier, &rep);
+ if (rc != Success)
+ return rc;
SendMappingNotify(MappingModifier, 0, 0, client);
for (dev = inputInfo.devices; dev; dev = dev->next)
@@ -1388,8 +1383,14 @@ ProcGetModifierMapping(ClientPtr client)
{
xGetModifierMappingReply rep;
KeyClassPtr keyc = inputInfo.keyboard->key;
-
+ int rc;
REQUEST_SIZE_MATCH(xReq);
+
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard,
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
rep.type = X_Reply;
rep.numKeyPerModifier = keyc->maxKeysPerModifier;
rep.sequenceNumber = client->sequence;
@@ -1412,6 +1413,7 @@ ProcChangeKeyboardMapping(ClientPtr client)
KeySymsRec keysyms;
KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
DeviceIntPtr pDev = NULL;
+ int rc;
REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2);
@@ -1432,8 +1434,9 @@ ProcChangeKeyboardMapping(ClientPtr client)
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
- if (!XaceHook(XACE_DEVICE_ACCESS, client, pDev, TRUE))
- return BadAccess;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
}
}
@@ -1458,9 +1461,9 @@ ProcChangeKeyboardMapping(ClientPtr client)
}
static int
-DoSetPointerMapping(DeviceIntPtr device, BYTE *map, int n)
+DoSetPointerMapping(ClientPtr client, DeviceIntPtr device, BYTE *map, int n)
{
- int i = 0;
+ int rc, i = 0;
DeviceIntPtr dev = NULL;
if (!device || !device->button)
@@ -1468,6 +1471,14 @@ DoSetPointerMapping(DeviceIntPtr device, BYTE *map, int n)
for (dev = inputInfo.devices; dev; dev = dev->next) {
if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+ }
+ }
+
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
for (i = 0; i < n; i++) {
if ((device->button->map[i + 1] != map[i]) &&
BitIsOn(device->button->down, i + 1)) {
@@ -1490,12 +1501,12 @@ DoSetPointerMapping(DeviceIntPtr device, BYTE *map, int n)
int
ProcSetPointerMapping(ClientPtr client)
{
- REQUEST(xSetPointerMappingReq);
BYTE *map;
int ret;
xSetPointerMappingReply rep;
-
+ REQUEST(xSetPointerMappingReq);
REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
+
if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2)
return BadLength;
rep.type = X_Reply;
@@ -1513,7 +1524,7 @@ ProcSetPointerMapping(ClientPtr client)
if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue))
return BadValue;
- ret = DoSetPointerMapping(inputInfo.pointer, map, stuff->nElts);
+ ret = DoSetPointerMapping(client, inputInfo.pointer, map, stuff->nElts);
if (ret != Success) {
rep.success = ret;
WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
@@ -1530,11 +1541,16 @@ int
ProcGetKeyboardMapping(ClientPtr client)
{
xGetKeyboardMappingReply rep;
- REQUEST(xGetKeyboardMappingReq);
KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
-
+ int rc;
+ REQUEST(xGetKeyboardMappingReq);
REQUEST_SIZE_MATCH(xGetKeyboardMappingReq);
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard,
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
(stuff->firstKeyCode > curKeySyms->maxKeyCode)) {
client->errorValue = stuff->firstKeyCode;
@@ -1567,8 +1583,14 @@ ProcGetPointerMapping(ClientPtr client)
{
xGetPointerMappingReply rep;
ButtonClassPtr butc = inputInfo.pointer->button;
-
+ int rc;
REQUEST_SIZE_MATCH(xReq);
+
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.pointer,
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
rep.nElts = butc->numButtons;
@@ -1787,8 +1809,9 @@ ProcChangeKeyboardControl (ClientPtr client)
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
if ((pDev->coreEvents || pDev == inputInfo.keyboard) &&
pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
- if (!XaceHook(XACE_DEVICE_ACCESS, client, pDev, TRUE))
- return BadAccess;
+ ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixSetAttrAccess);
+ if (ret != Success)
+ return ret;
}
}
@@ -1807,11 +1830,16 @@ ProcChangeKeyboardControl (ClientPtr client)
int
ProcGetKeyboardControl (ClientPtr client)
{
- int i;
+ int rc, i;
KeybdCtrl *ctrl = &inputInfo.keyboard->kbdfeed->ctrl;
xGetKeyboardControlReply rep;
-
REQUEST_SIZE_MATCH(xReq);
+
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard,
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
rep.type = X_Reply;
rep.length = 5;
rep.sequenceNumber = client->sequence;
@@ -1833,6 +1861,7 @@ ProcBell(ClientPtr client)
DeviceIntPtr keybd = inputInfo.keyboard;
int base = keybd->kbdfeed->ctrl.bell;
int newpercent;
+ int rc;
REQUEST(xBellReq);
REQUEST_SIZE_MATCH(xBellReq);
@@ -1853,6 +1882,10 @@ ProcBell(ClientPtr client)
for (keybd = inputInfo.devices; keybd; keybd = keybd->next) {
if ((keybd->coreEvents || keybd == inputInfo.keyboard) &&
keybd->kbdfeed && keybd->kbdfeed->BellProc) {
+
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixBellAccess);
+ if (rc != Success)
+ return rc;
#ifdef XKB
if (!noXkbExtension)
XkbHandleBell(FALSE, FALSE, keybd, newpercent,
@@ -1872,8 +1905,8 @@ ProcChangePointerControl(ClientPtr client)
{
DeviceIntPtr mouse = inputInfo.pointer;
PtrCtrl ctrl; /* might get BadValue part way through */
+ int rc;
REQUEST(xChangePointerControlReq);
-
REQUEST_SIZE_MATCH(xChangePointerControlReq);
if (!mouse->ptrfeed->CtrlProc)
@@ -1924,6 +1957,14 @@ ProcChangePointerControl(ClientPtr client)
}
}
+ for (mouse = inputInfo.devices; mouse; mouse = mouse->next) {
+ if ((mouse->coreEvents || mouse == inputInfo.pointer) &&
+ mouse->ptrfeed && mouse->ptrfeed->CtrlProc) {
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+ }
+ }
for (mouse = inputInfo.devices; mouse; mouse = mouse->next) {
if ((mouse->coreEvents || mouse == inputInfo.pointer) &&
@@ -1941,8 +1982,14 @@ ProcGetPointerControl(ClientPtr client)
{
PtrCtrl *ctrl = &inputInfo.pointer->ptrfeed->ctrl;
xGetPointerControlReply rep;
-
+ int rc;
REQUEST_SIZE_MATCH(xReq);
+
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.pointer,
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@@ -1980,11 +2027,15 @@ ProcGetMotionEvents(ClientPtr client)
DeviceIntPtr mouse = inputInfo.pointer;
TimeStamp start, stop;
REQUEST(xGetMotionEventsReq);
-
REQUEST_SIZE_MATCH(xGetMotionEventsReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess);
if (rc != Success)
return rc;
+
if (mouse->valuator->motionHintWindow)
MaybeStopHint(mouse, client);
rep.type = X_Reply;
@@ -2040,7 +2091,7 @@ int
ProcQueryKeymap(ClientPtr client)
{
xQueryKeymapReply rep;
- int i;
+ int rc, i;
CARD8 *down = inputInfo.keyboard->key->down;
REQUEST_SIZE_MATCH(xReq);
@@ -2048,11 +2099,13 @@ ProcQueryKeymap(ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.length = 2;
- if (XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, TRUE))
- for (i = 0; i<32; i++)
- rep.map[i] = down[i];
- else
- bzero((char *)&rep.map[0], 32);
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard,
+ DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ for (i = 0; i<32; i++)
+ rep.map[i] = down[i];
WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep);
return Success;
diff --git a/dix/dispatch.c b/dix/dispatch.c
index c356aed30..577e17cf0 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -134,6 +134,7 @@ int ProcInitialConnection();
#include "panoramiX.h"
#include "panoramiXsrv.h"
#endif
+#include "privates.h"
#include "xace.h"
#ifdef XAPPGROUP
#include "appgroup.h"
@@ -147,14 +148,8 @@ int ProcInitialConnection();
#endif
#ifdef XSERVER_DTRACE
-#include <sys/types.h>
-typedef const char *string;
+#include "registry.h"
#include "Xserver-dtrace.h"
-
-char *RequestNames[256];
-static void LoadRequestNames(void);
-static void FreeRequestNames(void);
-#define GetRequestName(i) (RequestNames[i])
#endif
#define mskcnt ((MAXCLIENTS + 31) / 32)
@@ -257,34 +252,6 @@ InitSelections(void)
CurrentSelections = (Selection *)NULL;
NumCurrentSelections = 0;
}
-
-void
-FlushClientCaches(XID id)
-{
- int i;
- ClientPtr client;
-
- client = clients[CLIENT_ID(id)];
- if (client == NullClient)
- return ;
- for (i=0; i<currentMaxClients; i++)
- {
- client = clients[i];
- if (client != NullClient)
- {
- if (client->lastDrawableID == id)
- {
- client->lastDrawableID = WindowTable[0]->drawable.id;
- client->lastDrawable = (DrawablePtr)WindowTable[0];
- }
- else if (client->lastGCID == id)
- {
- client->lastGCID = INVALID;
- client->lastGC = (GCPtr)NULL;
- }
- }
- }
-}
#ifdef SMART_SCHEDULE
#undef SMART_DEBUG
@@ -410,10 +377,6 @@ Dispatch(void)
if (!clientReady)
return;
-#ifdef XSERVER_DTRACE
- LoadRequestNames();
-#endif
-
while (!dispatchException)
{
if (*icheck[0] != *icheck[1])
@@ -491,7 +454,7 @@ Dispatch(void)
client->requestLogIndex++;
#endif
#ifdef XSERVER_DTRACE
- XSERVER_REQUEST_START(GetRequestName(MAJOROP), MAJOROP,
+ XSERVER_REQUEST_START(LookupMajorName(MAJOROP), MAJOROP,
((xReq *)client->requestBuffer)->length,
client->index, client->requestBuffer);
#endif
@@ -503,7 +466,7 @@ Dispatch(void)
XaceHookAuditEnd(client, result);
}
#ifdef XSERVER_DTRACE
- XSERVER_REQUEST_DONE(GetRequestName(MAJOROP), MAJOROP,
+ XSERVER_REQUEST_DONE(LookupMajorName(MAJOROP), MAJOROP,
client->sequence, client->index, result);
#endif
@@ -537,9 +500,6 @@ Dispatch(void)
KillAllClients();
xfree(clientReady);
dispatchException &= ~DE_RESET;
-#ifdef XSERVER_DTRACE
- FreeRequestNames();
-#endif
}
#undef MAJOROP
@@ -555,12 +515,12 @@ ProcCreateWindow(ClientPtr client)
{
WindowPtr pParent, pWin;
REQUEST(xCreateWindowReq);
- int result, len, rc;
+ int len, rc;
REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
LEGAL_NEW_RESOURCE(stuff->wid, client);
- rc = dixLookupWindow(&pParent, stuff->parent, client, DixWriteAccess);
+ rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess);
if (rc != Success)
return rc;
len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
@@ -576,7 +536,7 @@ ProcCreateWindow(ClientPtr client)
stuff->borderWidth, stuff->class,
stuff->mask, (XID *) &stuff[1],
(int)stuff->depth,
- client, stuff->visual, &result);
+ client, stuff->visual, &rc);
if (pWin)
{
Mask mask = pWin->eventMask;
@@ -589,7 +549,7 @@ ProcCreateWindow(ClientPtr client)
if (client->noClientException != Success)
return(client->noClientException);
else
- return(result);
+ return rc;
}
int
@@ -597,11 +557,13 @@ ProcChangeWindowAttributes(ClientPtr client)
{
WindowPtr pWin;
REQUEST(xChangeWindowAttributesReq);
- int result;
- int len, rc;
+ int result, len, rc;
+ Mask access_mode = 0;
REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+ access_mode |= (stuff->valueMask & CWEventMask) ? DixReceiveAccess : 0;
+ access_mode |= (stuff->valueMask & ~CWEventMask) ? DixSetAttrAccess : 0;
+ rc = dixLookupWindow(&pWin, stuff->window, client, access_mode);
if (rc != Success)
return rc;
len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
@@ -626,7 +588,7 @@ ProcGetWindowAttributes(ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
return rc;
GetWindowAttributes(pWin, client, &wa);
@@ -645,8 +607,13 @@ ProcDestroyWindow(ClientPtr client)
rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess);
if (rc != Success)
return rc;
- if (pWin->parent)
+ if (pWin->parent) {
+ rc = dixLookupWindow(&pWin, pWin->parent->drawable.id, client,
+ DixRemoveAccess);
+ if (rc != Success)
+ return rc;
FreeResource(stuff->id, RT_NONE);
+ }
return(client->noClientException);
}
@@ -658,7 +625,7 @@ ProcDestroySubwindows(ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess);
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixRemoveAccess);
if (rc != Success)
return rc;
DestroySubwindows(pWin, client);
@@ -673,7 +640,7 @@ ProcChangeSaveSet(ClientPtr client)
int result, rc;
REQUEST_SIZE_MATCH(xChangeSaveSetReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
if (rc != Success)
return rc;
if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
@@ -701,10 +668,10 @@ ProcReparentWindow(ClientPtr client)
int result, rc;
REQUEST_SIZE_MATCH(xReparentWindowReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
if (rc != Success)
return rc;
- rc = dixLookupWindow(&pParent, stuff->parent, client, DixWriteAccess);
+ rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess);
if (rc != Success)
return rc;
if (SAME_SCREENS(pWin->drawable, pParent->drawable))
@@ -734,7 +701,7 @@ ProcMapWindow(ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixShowAccess);
if (rc != Success)
return rc;
MapWindow(pWin, client);
@@ -750,7 +717,7 @@ ProcMapSubwindows(ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
if (rc != Success)
return rc;
MapSubwindows(pWin, client);
@@ -766,7 +733,7 @@ ProcUnmapWindow(ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixHideAccess);
if (rc != Success)
return rc;
UnmapWindow(pWin, FALSE);
@@ -782,7 +749,7 @@ ProcUnmapSubwindows(ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
if (rc != Success)
return rc;
UnmapSubwindows(pWin);
@@ -798,7 +765,8 @@ ProcConfigureWindow(ClientPtr client)
int len, rc;
REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client,
+ DixManageAccess|DixSetAttrAccess);
if (rc != Success)
return rc;
len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
@@ -826,7 +794,7 @@ ProcCirculateWindow(ClientPtr client)
client->errorValue = stuff->direction;
return BadValue;
}
- rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
if (rc != Success)
return rc;
CirculateWindow(pWin, (int)stuff->direction, client);
@@ -841,7 +809,7 @@ GetGeometry(ClientPtr client, xGetGeometryReply *rep)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixReadAccess);
+ rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -902,7 +870,7 @@ ProcQueryTree(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess);
if (rc != Success)
return rc;
reply.type = X_Reply;
@@ -1001,9 +969,10 @@ ProcSetSelectionOwner(ClientPtr client)
{
WindowPtr pWin;
TimeStamp time;
+ int rc;
REQUEST(xSetSelectionOwnerReq);
-
REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+
UpdateCurrentTime();
time = ClientTimeToServerTime(stuff->time);
@@ -1013,7 +982,7 @@ ProcSetSelectionOwner(ClientPtr client)
return Success;
if (stuff->window != None)
{
- int rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess);
if (rc != Success)
return rc;
}
@@ -1023,6 +992,11 @@ ProcSetSelectionOwner(ClientPtr client)
{
int i = 0;
+ rc = XaceHook(XACE_SELECTION_ACCESS, client, stuff->selection,
+ DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+
/*
* First, see if the selection is already set...
*/
@@ -1069,6 +1043,7 @@ ProcSetSelectionOwner(ClientPtr client)
NumCurrentSelections++;
CurrentSelections = newsels;
CurrentSelections[i].selection = stuff->selection;
+ CurrentSelections[i].devPrivates = NULL;
}
CurrentSelections[i].lastTimeChanged = time;
CurrentSelections[i].window = stuff->window;
@@ -1079,6 +1054,7 @@ ProcSetSelectionOwner(ClientPtr client)
SelectionInfoRec info;
info.selection = &CurrentSelections[i];
+ info.client = client;
info.kind= SelectionSetOwner;
CallCallbacks(&SelectionCallback, &info);
}
@@ -1099,18 +1075,31 @@ ProcGetSelectionOwner(ClientPtr client)
REQUEST_SIZE_MATCH(xResourceReq);
if (ValidAtom(stuff->id))
{
- int i;
+ int rc, i;
xGetSelectionOwnerReply reply;
+ rc = XaceHook(XACE_SELECTION_ACCESS, client, stuff->id,
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
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)
+ if (i < NumCurrentSelections) {
+ if (SelectionCallback) {
+ SelectionInfoRec info;
+
+ info.selection = &CurrentSelections[i];
+ info.client = client;
+ info.kind= SelectionGetOwner;
+ CallCallbacks(&SelectionCallback, &info);
+ }
reply.owner = CurrentSelections[i].window;
- else
+ } else
reply.owner = None;
WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply);
return(client->noClientException);
@@ -1132,9 +1121,13 @@ ProcConvertSelection(ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xConvertSelectionReq);
- rc = dixLookupWindow(&pWin, stuff->requestor, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->requestor, client, DixSetAttrAccess);
if (rc != Success)
return rc;
+ rc = XaceHook(XACE_SELECTION_ACCESS, client, stuff->selection,
+ DixReadAccess);
+ if (rc != Success)
+ return rc;
paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target));
if (stuff->property != None)
@@ -1146,16 +1139,18 @@ ProcConvertSelection(ClientPtr client)
i = 0;
while ((i < NumCurrentSelections) &&
CurrentSelections[i].selection != stuff->selection) i++;
- if ((i < NumCurrentSelections) &&
- (CurrentSelections[i].window != None) &&
- XaceHook(XACE_RESOURCE_ACCESS, client,
- CurrentSelections[i].window, RT_WINDOW,
- DixReadAccess, CurrentSelections[i].pWin))
- {
+ if (i < NumCurrentSelections && CurrentSelections[i].window != None) {
+ if (SelectionCallback) {
+ SelectionInfoRec info;
+
+ info.selection = &CurrentSelections[i];
+ info.client = client;
+ info.kind= SelectionConvertSelection;
+ CallCallbacks(&SelectionCallback, &info);
+ }
event.u.u.type = SelectionRequest;
event.u.selectionRequest.time = stuff->time;
- event.u.selectionRequest.owner =
- CurrentSelections[i].window;
+ 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;
@@ -1185,6 +1180,7 @@ ProcConvertSelection(ClientPtr client)
int
ProcGrabServer(ClientPtr client)
{
+ int rc;
REQUEST_SIZE_MATCH(xReq);
if (grabState != GrabNone && client != grabClient)
{
@@ -1194,7 +1190,9 @@ ProcGrabServer(ClientPtr client)
IgnoreClient(client);
return(client->noClientException);
}
- OnlyListenToOneClient(client);
+ rc = OnlyListenToOneClient(client);
+ if (rc != Success)
+ return rc;
grabState = GrabKickout;
grabClient = client;
@@ -1254,10 +1252,10 @@ ProcTranslateCoords(ClientPtr client)
int rc;
REQUEST_SIZE_MATCH(xTranslateCoordsReq);
- rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
- rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess);
+ rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep.type = X_Reply;
@@ -1367,23 +1365,21 @@ ProcQueryFont(ClientPtr client)
xQueryFontReply *reply;
FontPtr pFont;
GC *pGC;
+ int rc;
REQUEST(xResourceReq);
-
REQUEST_SIZE_MATCH(xResourceReq);
+
client->errorValue = stuff->id; /* EITHER font or gc */
- pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT,
- DixReadAccess);
- if (!pFont)
- {
- pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC,
- DixReadAccess);
- if (!pGC)
- {
- client->errorValue = stuff->id;
- return(BadFont); /* procotol spec says only error is BadFont */
- }
- pFont = pGC->font;
+ rc = dixLookupResource((pointer *)&pFont, stuff->id, RT_FONT, client,
+ DixGetAttrAccess);
+ if (rc == BadValue) {
+ rc = dixLookupResource((pointer *)&pGC, stuff->id, RT_GC, client,
+ DixGetAttrAccess);
+ if (rc == Success)
+ pFont = pGC->font;
}
+ if (rc != Success)
+ return (rc == BadValue) ? BadFont: rc;
{
xCharInfo *pmax = FONTINKMAX(pFont);
@@ -1422,28 +1418,27 @@ ProcQueryFont(ClientPtr client)
int
ProcQueryTextExtents(ClientPtr client)
{
- REQUEST(xQueryTextExtentsReq);
xQueryTextExtentsReply reply;
FontPtr pFont;
GC *pGC;
ExtentInfoRec info;
unsigned long length;
-
+ int rc;
+ REQUEST(xQueryTextExtentsReq);
REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq);
- pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT,
- DixReadAccess);
- if (!pFont)
- {
- pGC = (GC *)SecurityLookupIDByType(client, stuff->fid, RT_GC,
- DixReadAccess);
- if (!pGC)
- {
- client->errorValue = stuff->fid;
- return(BadFont);
- }
- pFont = pGC->font;
+ client->errorValue = stuff->fid; /* EITHER font or gc */
+ rc = dixLookupResource((pointer *)&pFont, stuff->fid, RT_FONT, client,
+ DixGetAttrAccess);
+ if (rc == BadValue) {
+ rc = dixLookupResource((pointer *)&pGC, stuff->fid, RT_GC, client,
+ DixGetAttrAccess);
+ if (rc == Success)
+ pFont = pGC->font;
}
+ if (rc != Success)
+ return (rc == BadValue) ? BadFont: rc;
+
length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2);
length = length << 1;
if (stuff->oddLength)
@@ -1516,7 +1511,7 @@ ProcCreatePixmap(ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->pid, client);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY,
- DixReadAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -1559,9 +1554,17 @@ CreatePmap:
{
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;
+ /* security creation/labeling check */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP,
+ pMap, RT_NONE, NULL, DixCreateAccess);
+ if (rc != Success) {
+ (*pDraw->pScreen->DestroyPixmap)(pMap);
+ return rc;
+ }
if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
return(client->noClientException);
}
+ (*pDraw->pScreen->DestroyPixmap)(pMap);
return (BadAlloc);
}
@@ -1569,13 +1572,13 @@ int
ProcFreePixmap(ClientPtr client)
{
PixmapPtr pMap;
-
+ int rc;
REQUEST(xResourceReq);
-
REQUEST_SIZE_MATCH(xResourceReq);
- pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP,
- DixDestroyAccess);
- if (pMap)
+
+ rc = dixLookupResource((pointer *)&pMap, stuff->id, RT_PIXMAP, client,
+ DixDestroyAccess);
+ if (rc == Success)
{
FreeResource(stuff->id, RT_NONE);
return(client->noClientException);
@@ -1583,7 +1586,7 @@ ProcFreePixmap(ClientPtr client)
else
{
client->errorValue = stuff->id;
- return (BadPixmap);
+ return (rc == BadValue) ? BadPixmap : rc;
}
}
@@ -1599,15 +1602,16 @@ ProcCreateGC(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xCreateGCReq);
client->errorValue = stuff->gc;
LEGAL_NEW_RESOURCE(stuff->gc, client);
- rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReadAccess);
+ rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
+ DixGetAttrAccess);
if (rc != Success)
return rc;
len = client->req_len - (sizeof(xCreateGCReq) >> 2);
if (len != Ones(stuff->mask))
return BadLength;
- pGC = (GC *)CreateGC(pDraw, stuff->mask,
- (XID *) &stuff[1], &error);
+ pGC = (GC *)CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error,
+ stuff->gc, client);
if (error != Success)
return error;
if (!AddResource(stuff->gc, RT_GC, (pointer)pGC))
@@ -1624,7 +1628,7 @@ ProcChangeGC(ClientPtr client)
REQUEST(xChangeGCReq);
REQUEST_AT_LEAST_SIZE(xChangeGCReq);
- result = dixLookupGC(&pGC, stuff->gc, client, DixWriteAccess);
+ result = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess);
if (result != Success)
return result;
@@ -1651,10 +1655,10 @@ ProcCopyGC(ClientPtr client)
REQUEST(xCopyGCReq);
REQUEST_SIZE_MATCH(xCopyGCReq);
- result = dixLookupGC(&pGC, stuff->srcGC, client, DixReadAccess);
+ result = dixLookupGC(&pGC, stuff->srcGC, client, DixGetAttrAccess);
if (result != Success)
return result;
- result = dixLookupGC(&dstGC, stuff->dstGC, client, DixWriteAccess);
+ result = dixLookupGC(&dstGC, stuff->dstGC, client, DixSetAttrAccess);
if (result != Success)
return result;
if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth))
@@ -1683,7 +1687,7 @@ ProcSetDashes(ClientPtr client)
return BadValue;
}
- result = dixLookupGC(&pGC,stuff->gc, client, DixWriteAccess);
+ result = dixLookupGC(&pGC,stuff->gc, client, DixSetAttrAccess);
if (result != Success)
return result;
@@ -1712,7 +1716,7 @@ ProcSetClipRectangles(ClientPtr client)
client->errorValue = stuff->ordering;
return BadValue;
}
- result = dixLookupGC(&pGC,stuff->gc, client, DixWriteAccess);
+ result = dixLookupGC(&pGC,stuff->gc, client, DixSetAttrAccess);
if (result != Success)
return result;
@@ -1783,7 +1787,7 @@ ProcCopyArea(ClientPtr client)
REQUEST_SIZE_MATCH(xCopyAreaReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess);
if (stuff->dstDrawable != stuff->srcDrawable)
{
rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0,
@@ -1824,7 +1828,7 @@ ProcCopyPlane(ClientPtr client)
REQUEST_SIZE_MATCH(xCopyPlaneReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess);
if (stuff->dstDrawable != stuff->srcDrawable)
{
rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0,
@@ -1877,7 +1881,7 @@ ProcPolyPoint(ClientPtr client)
client->errorValue = stuff->coordMode;
return BadValue;
}
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
if (npoint)
(*pGC->ops->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint,
@@ -1900,7 +1904,7 @@ ProcPolyLine(ClientPtr client)
client->errorValue = stuff->coordMode;
return BadValue;
}
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
if (npoint > 1)
(*pGC->ops->Polylines)(pDraw, pGC, stuff->coordMode, npoint,
@@ -1917,7 +1921,7 @@ ProcPolySegment(ClientPtr client)
REQUEST(xPolySegmentReq);
REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
if (nsegs & 4)
return(BadLength);
@@ -1936,7 +1940,7 @@ ProcPolyRectangle (ClientPtr client)
REQUEST(xPolyRectangleReq);
REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
if (nrects & 4)
return(BadLength);
@@ -1956,7 +1960,7 @@ ProcPolyArc(ClientPtr client)
REQUEST(xPolyArcReq);
REQUEST_AT_LEAST_SIZE(xPolyArcReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
if (narcs % sizeof(xArc))
return(BadLength);
@@ -1988,7 +1992,7 @@ ProcFillPoly(ClientPtr client)
return BadValue;
}
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
things = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
if (things)
(*pGC->ops->FillPolygon) (pDraw, pGC, stuff->shape,
@@ -2006,7 +2010,7 @@ ProcPolyFillRectangle(ClientPtr client)
REQUEST(xPolyFillRectangleReq);
REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
if (things & 4)
return(BadLength);
@@ -2027,7 +2031,7 @@ ProcPolyFillArc(ClientPtr client)
REQUEST(xPolyFillArcReq);
REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
if (narcs % sizeof(xArc))
return(BadLength);
@@ -2102,7 +2106,7 @@ ProcPutImage(ClientPtr client)
REQUEST(xPutImageReq);
REQUEST_AT_LEAST_SIZE(xPutImageReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
if (stuff->format == XYBitmap)
{
if ((stuff->depth != 1) ||
@@ -2265,8 +2269,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
}
- if (pDraw->type == DRAWABLE_WINDOW &&
- !XaceHook(XACE_DRAWABLE_ACCESS, client, pDraw))
+ if (pDraw->type == DRAWABLE_WINDOW)
{
pVisibleRegion = NotClippedByChildren((WindowPtr)pDraw);
if (pVisibleRegion)
@@ -2388,7 +2391,7 @@ ProcPolyText(ClientPtr client)
GC *pGC;
REQUEST_AT_LEAST_SIZE(xPolyTextReq);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
err = PolyText(client,
pDraw,
@@ -2418,7 +2421,7 @@ ProcImageText8(ClientPtr client)
REQUEST(xImageTextReq);
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
err = ImageText(client,
pDraw,
@@ -2448,7 +2451,7 @@ ProcImageText16(ClientPtr client)
REQUEST(xImageTextReq);
REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
- VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
+ VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
err = ImageText(client,
pDraw,
@@ -2489,7 +2492,7 @@ ProcCreateColormap(ClientPtr client)
}
mid = stuff->mid;
LEGAL_NEW_RESOURCE(mid, client);
- result = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ result = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (result != Success)
return result;
@@ -2515,12 +2518,13 @@ int
ProcFreeColormap(ClientPtr client)
{
ColormapPtr pmap;
+ int rc;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- pmap = (ColormapPtr )SecurityLookupIDByType(client, stuff->id, RT_COLORMAP,
- DixDestroyAccess);
- if (pmap)
+ rc = dixLookupResource((pointer *)&pmap, stuff->id, RT_COLORMAP, client,
+ DixDestroyAccess);
+ if (rc == Success)
{
/* Freeing a default colormap is a no-op */
if (!(pmap->flags & IsDefault))
@@ -2530,7 +2534,7 @@ ProcFreeColormap(ClientPtr client)
else
{
client->errorValue = stuff->id;
- return (BadColor);
+ return rc;
}
}
@@ -2541,24 +2545,25 @@ ProcCopyColormapAndFree(ClientPtr client)
Colormap mid;
ColormapPtr pSrcMap;
REQUEST(xCopyColormapAndFreeReq);
- int result;
+ int rc;
REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
mid = stuff->mid;
LEGAL_NEW_RESOURCE(mid, client);
- if( (pSrcMap = (ColormapPtr )SecurityLookupIDByType(client, stuff->srcCmap,
- RT_COLORMAP, DixReadAccess|DixWriteAccess)) )
+ rc = dixLookupResource((pointer *)&pSrcMap, stuff->srcCmap, RT_COLORMAP,
+ client, DixReadAccess|DixRemoveAccess);
+ if (rc == Success)
{
- result = CopyColormapAndFree(mid, pSrcMap, client->index);
+ rc = CopyColormapAndFree(mid, pSrcMap, client->index);
if (client->noClientException != Success)
return(client->noClientException);
else
- return(result);
+ return rc;
}
else
{
client->errorValue = stuff->srcCmap;
- return(BadColor);
+ return rc;
}
}
@@ -2566,43 +2571,51 @@ int
ProcInstallColormap(ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xResourceReq);
-
REQUEST_SIZE_MATCH(xResourceReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
- RT_COLORMAP, DixReadAccess);
- if (pcmp)
- {
- (*(pcmp->pScreen->InstallColormap)) (pcmp);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadColor);
- }
+
+ rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
+ DixInstallAccess);
+ if (rc != Success)
+ goto out;
+
+ rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess);
+ if (rc != Success)
+ goto out;
+
+ (*(pcmp->pScreen->InstallColormap)) (pcmp);
+
+ rc = client->noClientException;
+out:
+ client->errorValue = stuff->id;
+ return (rc == BadValue) ? BadColor : rc;
}
int
ProcUninstallColormap(ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xResourceReq);
-
REQUEST_SIZE_MATCH(xResourceReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->id,
- RT_COLORMAP, DixReadAccess);
- if (pcmp)
- {
- if(pcmp->mid != pcmp->pScreen->defColormap)
- (*(pcmp->pScreen->UninstallColormap)) (pcmp);
- return (client->noClientException);
- }
- else
- {
- client->errorValue = stuff->id;
- return (BadColor);
- }
+
+ rc = dixLookupResource((pointer *)&pcmp, stuff->id, RT_COLORMAP, client,
+ DixUninstallAccess);
+ if (rc != Success)
+ goto out;
+
+ rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess);
+ if (rc != Success)
+ goto out;
+
+ if(pcmp->mid != pcmp->pScreen->defColormap)
+ (*(pcmp->pScreen->UninstallColormap)) (pcmp);
+
+ rc = client->noClientException;
+out:
+ client->errorValue = stuff->id;
+ return (rc == BadValue) ? BadColor : rc;
}
int
@@ -2612,11 +2625,16 @@ ProcListInstalledColormaps(ClientPtr client)
int nummaps, rc;
WindowPtr pWin;
REQUEST(xResourceReq);
-
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
- return rc;
+ goto out;
+
+ rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen,
+ DixGetAttrAccess);
+ if (rc != Success)
+ goto out;
preply = (xListInstalledColormapsReply *)
xalloc(sizeof(xListInstalledColormapsReply) +
@@ -2635,21 +2653,23 @@ ProcListInstalledColormaps(ClientPtr client)
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
xfree(preply);
- return(client->noClientException);
+ rc = client->noClientException;
+out:
+ return (rc == BadValue) ? BadColor : rc;
}
int
ProcAllocColor (ClientPtr client)
{
ColormapPtr pmap;
- int retval;
+ int rc;
xAllocColorReply acr;
REQUEST(xAllocColorReq);
REQUEST_SIZE_MATCH(xAllocColorReq);
- pmap = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, DixWriteAccess);
- if (pmap)
+ rc = dixLookupResource((pointer *)&pmap, stuff->cmap, RT_COLORMAP, client,
+ DixAddAccess);
+ if (rc == Success)
{
acr.type = X_Reply;
acr.length = 0;
@@ -2658,13 +2678,13 @@ ProcAllocColor (ClientPtr client)
acr.green = stuff->green;
acr.blue = stuff->blue;
acr.pixel = 0;
- if( (retval = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
+ if( (rc = AllocColor(pmap, &acr.red, &acr.green, &acr.blue,
&acr.pixel, client->index)) )
{
if (client->noClientException != Success)
return(client->noClientException);
else
- return (retval);
+ return rc;
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pmap->pScreen->myNum)
@@ -2676,7 +2696,7 @@ ProcAllocColor (ClientPtr client)
else
{
client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
@@ -2684,15 +2704,14 @@ int
ProcAllocNamedColor (ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xAllocNamedColorReq);
REQUEST_FIXED_SIZE(xAllocNamedColorReq, stuff->nbytes);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, DixWriteAccess);
- if (pcmp)
+ rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
+ DixAddAccess);
+ if (rc == Success)
{
- int retval;
-
xAllocNamedColorReply ancr;
ancr.type = X_Reply;
@@ -2706,14 +2725,14 @@ ProcAllocNamedColor (ClientPtr client)
ancr.screenGreen = ancr.exactGreen;
ancr.screenBlue = ancr.exactBlue;
ancr.pixel = 0;
- if( (retval = AllocColor(pcmp,
+ if( (rc = AllocColor(pcmp,
&ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue,
&ancr.pixel, client->index)) )
{
if (client->noClientException != Success)
return(client->noClientException);
else
- return(retval);
+ return rc;
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
@@ -2728,7 +2747,7 @@ ProcAllocNamedColor (ClientPtr client)
else
{
client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
@@ -2736,15 +2755,16 @@ int
ProcAllocColorCells (ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xAllocColorCellsReq);
REQUEST_SIZE_MATCH(xAllocColorCellsReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, DixWriteAccess);
- if (pcmp)
+ rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
+ DixAddAccess);
+ if (rc == Success)
{
xAllocColorCellsReply accr;
- int npixels, nmasks, retval;
+ int npixels, nmasks;
long length;
Pixel *ppixels, *pmasks;
@@ -2766,14 +2786,14 @@ ProcAllocColorCells (ClientPtr client)
return(BadAlloc);
pmasks = ppixels + npixels;
- if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks,
+ if( (rc = AllocColorCells(client->index, pcmp, npixels, nmasks,
(Bool)stuff->contiguous, ppixels, pmasks)) )
{
xfree(ppixels);
if (client->noClientException != Success)
return(client->noClientException);
else
- return(retval);
+ return rc;
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pcmp->pScreen->myNum)
@@ -2794,7 +2814,7 @@ ProcAllocColorCells (ClientPtr client)
else
{
client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
@@ -2802,15 +2822,16 @@ int
ProcAllocColorPlanes(ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xAllocColorPlanesReq);
REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, DixWriteAccess);
- if (pcmp)
+ rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
+ DixAddAccess);
+ if (rc == Success)
{
xAllocColorPlanesReply acpr;
- int npixels, retval;
+ int npixels;
long length;
Pixel *ppixels;
@@ -2832,7 +2853,7 @@ ProcAllocColorPlanes(ClientPtr client)
ppixels = (Pixel *)xalloc(length);
if(!ppixels)
return(BadAlloc);
- if( (retval = AllocColorPlanes(client->index, pcmp, npixels,
+ if( (rc = AllocColorPlanes(client->index, pcmp, npixels,
(int)stuff->red, (int)stuff->green, (int)stuff->blue,
(Bool)stuff->contiguous, ppixels,
&acpr.redMask, &acpr.greenMask, &acpr.blueMask)) )
@@ -2841,7 +2862,7 @@ ProcAllocColorPlanes(ClientPtr client)
if (client->noClientException != Success)
return(client->noClientException);
else
- return(retval);
+ return rc;
}
acpr.length = length >> 2;
#ifdef PANORAMIX
@@ -2858,7 +2879,7 @@ ProcAllocColorPlanes(ClientPtr client)
else
{
client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
@@ -2866,34 +2887,34 @@ int
ProcFreeColors(ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xFreeColorsReq);
REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, DixWriteAccess);
- if (pcmp)
+ rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
+ DixRemoveAccess);
+ if (rc == Success)
{
int count;
- int retval;
if(pcmp->flags & AllAllocated)
return(BadAccess);
count = ((client->req_len << 2)- sizeof(xFreeColorsReq)) >> 2;
- retval = FreeColors(pcmp, client->index, count,
+ rc = FreeColors(pcmp, client->index, count,
(Pixel *)&stuff[1], (Pixel)stuff->planeMask);
if (client->noClientException != Success)
return(client->noClientException);
else
{
client->errorValue = clientErrorValue;
- return(retval);
+ return rc;
}
}
else
{
client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
@@ -2901,33 +2922,33 @@ int
ProcStoreColors (ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xStoreColorsReq);
REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, DixWriteAccess);
- if (pcmp)
+ rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
+ DixWriteAccess);
+ if (rc == Success)
{
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]);
+ rc = StoreColors(pcmp, count, (xColorItem *)&stuff[1]);
if (client->noClientException != Success)
return(client->noClientException);
else
{
client->errorValue = clientErrorValue;
- return(retval);
+ return rc;
}
}
else
{
client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
@@ -2935,33 +2956,33 @@ int
ProcStoreNamedColor (ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xStoreNamedColorReq);
REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, DixWriteAccess);
- if (pcmp)
+ rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
+ DixWriteAccess);
+ if (rc == Success)
{
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);
+ rc = StoreColors(pcmp, 1, &def);
if (client->noClientException != Success)
return(client->noClientException);
else
- return(retval);
+ return rc;
}
return (BadName);
}
else
{
client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
@@ -2969,14 +2990,15 @@ int
ProcQueryColors(ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xQueryColorsReq);
REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, DixReadAccess);
- if (pcmp)
+ rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
+ DixReadAccess);
+ if (rc == Success)
{
- int count, retval;
+ int count;
xrgb *prgbs;
xQueryColorsReply qcr;
@@ -2984,7 +3006,7 @@ ProcQueryColors(ClientPtr client)
prgbs = (xrgb *)xalloc(count * sizeof(xrgb));
if(!prgbs && count)
return(BadAlloc);
- if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
+ if( (rc = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
{
if (prgbs) xfree(prgbs);
if (client->noClientException != Success)
@@ -2992,7 +3014,7 @@ ProcQueryColors(ClientPtr client)
else
{
client->errorValue = clientErrorValue;
- return (retval);
+ return rc;
}
}
qcr.type = X_Reply;
@@ -3012,7 +3034,7 @@ ProcQueryColors(ClientPtr client)
else
{
client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
@@ -3020,12 +3042,13 @@ int
ProcLookupColor(ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xLookupColorReq);
REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes);
- pcmp = (ColormapPtr)SecurityLookupIDByType(client, stuff->cmap,
- RT_COLORMAP, DixReadAccess);
- if (pcmp)
+ rc = dixLookupResource((pointer *)&pcmp, stuff->cmap, RT_COLORMAP, client,
+ DixReadAccess);
+ if (rc == Success)
{
xLookupColorReply lcr;
@@ -3050,7 +3073,7 @@ ProcLookupColor(ClientPtr client)
else
{
client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
@@ -3065,28 +3088,28 @@ ProcCreateCursor (ClientPtr client)
unsigned short width, height;
long n;
CursorMetricRec cm;
-
+ int rc;
REQUEST(xCreateCursorReq);
REQUEST_SIZE_MATCH(xCreateCursorReq);
LEGAL_NEW_RESOURCE(stuff->cid, client);
- src = (PixmapPtr)SecurityLookupIDByType(client, stuff->source,
- RT_PIXMAP, DixReadAccess);
- msk = (PixmapPtr)SecurityLookupIDByType(client, stuff->mask,
- RT_PIXMAP, DixReadAccess);
- if ( src == (PixmapPtr)NULL)
- {
+ rc = dixLookupResource((pointer *)&src, stuff->source, RT_PIXMAP, client,
+ DixReadAccess);
+ if (rc != Success) {
client->errorValue = stuff->source;
- return (BadPixmap);
+ return (rc == BadValue) ? BadPixmap : rc;
}
- if ( msk == (PixmapPtr)NULL)
+
+ rc = dixLookupResource((pointer *)&msk, stuff->mask, RT_PIXMAP, client,
+ DixReadAccess);
+ if (rc != Success)
{
if (stuff->mask != None)
{
client->errorValue = stuff->mask;
- return (BadPixmap);
+ return (rc == BadValue) ? BadPixmap : rc;
}
}
else if ( src->drawable.width != msk->drawable.width
@@ -3134,13 +3157,17 @@ ProcCreateCursor (ClientPtr client)
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);
+ rc = AllocARGBCursor(srcbits, mskbits, NULL, &cm,
+ stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
+ stuff->backRed, stuff->backGreen, stuff->backBlue,
+ &pCursor, client, stuff->cid);
- if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
- return (client->noClientException);
- return BadAlloc;
+ if (rc != Success)
+ return rc;
+ if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
+ return BadAlloc;
+
+ return client->noClientException;
}
int
@@ -3158,7 +3185,7 @@ ProcCreateGlyphCursor (ClientPtr client)
stuff->mask, stuff->maskChar,
stuff->foreRed, stuff->foreGreen, stuff->foreBlue,
stuff->backRed, stuff->backGreen, stuff->backBlue,
- &pCursor, client);
+ &pCursor, client, stuff->cid);
if (res != Success)
return res;
if (AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
@@ -3171,12 +3198,13 @@ int
ProcFreeCursor (ClientPtr client)
{
CursorPtr pCursor;
+ int rc;
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->id,
- RT_CURSOR, DixDestroyAccess);
- if (pCursor)
+ rc = dixLookupResource((pointer *)&pCursor, stuff->id, RT_CURSOR, client,
+ DixDestroyAccess);
+ if (rc == Success)
{
FreeResource(stuff->id, RT_NONE);
return (client->noClientException);
@@ -3184,7 +3212,7 @@ ProcFreeCursor (ClientPtr client)
else
{
client->errorValue = stuff->id;
- return (BadCursor);
+ return (rc == BadValue) ? BadCursor : rc;
}
}
@@ -3207,12 +3235,15 @@ ProcQueryBestSize (ClientPtr client)
}
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY,
- DixReadAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW)
return (BadMatch);
pScreen = pDraw->pScreen;
+ rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
(* pScreen->QueryBestSize)(stuff->class, &stuff->width,
&stuff->height, pScreen);
reply.type = X_Reply;
@@ -3228,10 +3259,17 @@ ProcQueryBestSize (ClientPtr client)
int
ProcSetScreenSaver (ClientPtr client)
{
- int blankingOption, exposureOption;
+ int rc, i, blankingOption, exposureOption;
REQUEST(xSetScreenSaverReq);
-
REQUEST_SIZE_MATCH(xSetScreenSaverReq);
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i],
+ DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+ }
+
blankingOption = stuff->preferBlank;
if ((blankingOption != DontPreferBlanking) &&
(blankingOption != PreferBlanking) &&
@@ -3285,8 +3323,16 @@ int
ProcGetScreenSaver(ClientPtr client)
{
xGetScreenSaverReply rep;
-
+ int rc, i;
REQUEST_SIZE_MATCH(xReq);
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i],
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+ }
+
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@@ -3333,8 +3379,9 @@ ProcListHosts(ClientPtr client)
REQUEST_SIZE_MATCH(xListHostsReq);
/* untrusted clients can't list hosts */
- if (!XaceHook(XACE_HOSTLIST_ACCESS, client, DixReadAccess))
- return BadAccess;
+ result = XaceHook(XACE_SERVER_ACCESS, client, DixReadAccess);
+ if (result != Success)
+ return result;
result = GetHosts(&pdata, &nHosts, &len, &reply.enabled);
if (result != Success)
@@ -3464,12 +3511,14 @@ int
ProcGetFontPath(ClientPtr client)
{
xGetFontPathReply reply;
- int stringLens, numpaths;
+ int rc, stringLens, numpaths;
unsigned char *bufferStart;
/* REQUEST (xReq); */
REQUEST_SIZE_MATCH(xReq);
- bufferStart = GetFontPath(&numpaths, &stringLens);
+ rc = GetFontPath(client, &numpaths, &stringLens, &bufferStart);
+ if (rc != Success)
+ return rc;
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
@@ -3485,9 +3534,14 @@ ProcGetFontPath(ClientPtr client)
int
ProcChangeCloseDownMode(ClientPtr client)
{
+ int rc;
REQUEST(xSetCloseDownModeReq);
-
REQUEST_SIZE_MATCH(xSetCloseDownModeReq);
+
+ rc = XaceHook(XACE_CLIENT_ACCESS, client, client, DixManageAccess);
+ if (rc != Success)
+ return rc;
+
if ((stuff->mode == AllTemporary) ||
(stuff->mode == RetainPermanent) ||
(stuff->mode == RetainTemporary))
@@ -3504,6 +3558,7 @@ ProcChangeCloseDownMode(ClientPtr client)
int ProcForceScreenSaver(ClientPtr client)
{
+ int rc;
REQUEST(xForceScreenSaverReq);
REQUEST_SIZE_MATCH(xForceScreenSaverReq);
@@ -3514,7 +3569,9 @@ int ProcForceScreenSaver(ClientPtr client)
client->errorValue = stuff->mode;
return BadValue;
}
- SaveScreens(SCREEN_SAVER_FORCER, (int)stuff->mode);
+ rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, (int)stuff->mode);
+ if (rc != Success)
+ return rc;
return client->noClientException;
}
@@ -3636,6 +3693,7 @@ CloseDownClient(ClientPtr client)
#ifdef SMART_SCHEDULE
SmartLastClient = NullClient;
#endif
+ dixFreePrivates(client->devPrivates);
xfree(client);
while (!clients[currentMaxClients-1])
@@ -3655,30 +3713,13 @@ KillAllClients(void)
}
}
-extern int clientPrivateLen;
-extern unsigned *clientPrivateSizes;
-extern unsigned totalClientSize;
-
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->closeDownMode = i ? DestroyAll : RetainPermanent;
client->numSaved = 0;
client->saveSet = (SaveSetElt *)NULL;
client->noClientException = Success;
@@ -3691,6 +3732,7 @@ void InitClient(ClientPtr client, int i, pointer ospriv)
client->big_requests = FALSE;
client->priority = 0;
client->clientState = ClientStateInitial;
+ client->devPrivates = NULL;
#ifdef XKB
if (!noXkbExtension) {
client->xkbClientFlags = 0;
@@ -3711,54 +3753,6 @@ void InitClient(ClientPtr client, int i, pointer ospriv)
#endif
}
-int
-InitClientPrivates(ClientPtr client)
-{
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- 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);
- if (ppriv)
- bzero(ppriv, totalClientSize - sizeof(ClientRec));
- for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
-
- /* Allow registrants to initialize the serverClient devPrivates */
- if (!client->index && ClientStateCallback)
- {
- NewClientInfoRec clientinfo;
-
- clientinfo.client = client;
- clientinfo.prefix = (xConnSetupPrefix *)NULL;
- clientinfo.setup = (xConnSetup *) NULL;
- CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
- }
- return 1;
-}
-
/************************
* int NextAvailableClient(ospriv)
*
@@ -3775,11 +3769,10 @@ ClientPtr NextAvailableClient(pointer ospriv)
i = nextFreeClientID;
if (i == MAXCLIENTS)
return (ClientPtr)NULL;
- clients[i] = client = (ClientPtr)xalloc(totalClientSize);
+ clients[i] = client = (ClientPtr)xalloc(sizeof(ClientRec));
if (!client)
return (ClientPtr)NULL;
InitClient(client, i, ospriv);
- InitClientPrivates(client);
if (!InitClientResources(client))
{
xfree(client);
@@ -4002,9 +3995,11 @@ DeleteWindowFromAnySelections(WindowPtr pWin)
info.kind = SelectionWindowDestroy;
CallCallbacks(&SelectionCallback, &info);
}
+ dixFreePrivates(CurrentSelections[i].devPrivates);
CurrentSelections[i].pWin = (WindowPtr)NULL;
CurrentSelections[i].window = None;
CurrentSelections[i].client = NullClient;
+ CurrentSelections[i].devPrivates = NULL;
}
}
@@ -4024,9 +4019,11 @@ DeleteClientFromAnySelections(ClientPtr client)
info.kind = SelectionWindowDestroy;
CallCallbacks(&SelectionCallback, &info);
}
+ dixFreePrivates(CurrentSelections[i].devPrivates);
CurrentSelections[i].pWin = (WindowPtr)NULL;
CurrentSelections[i].window = None;
CurrentSelections[i].client = NullClient;
+ CurrentSelections[i].devPrivates = NULL;
}
}
@@ -4035,60 +4032,3 @@ MarkClientException(ClientPtr client)
{
client->noClientException = -1;
}
-
-#ifdef XSERVER_DTRACE
-#include <ctype.h>
-
-/* Load table of request names for dtrace probes */
-static void LoadRequestNames(void)
-{
- int i;
- FILE *xedb;
- extern void LoadExtensionNames(char **RequestNames);
-
- bzero(RequestNames, 256 * sizeof(char *));
-
- xedb = fopen(XERRORDB_PATH, "r");
- if (xedb != NULL) {
- char buf[256];
- while (fgets(buf, sizeof(buf), xedb)) {
- if ((strncmp("XRequest.", buf, 9) == 0) && (isdigit(buf[9]))) {
- char *name;
- i = strtol(buf + 9, &name, 10);
- if (RequestNames[i] == 0) {
- char *end = strchr(name, '\n');
- if (end) { *end = '\0'; }
- RequestNames[i] = strdup(name + 1);
- }
- }
- }
- fclose(xedb);
- }
-
- LoadExtensionNames(RequestNames);
-
- for (i = 0; i < 256; i++) {
- if (RequestNames[i] == 0) {
-#define RN_SIZE 12 /* "Request#' + up to 3 digits + \0 */
- RequestNames[i] = xalloc(RN_SIZE);
- if (RequestNames[i]) {
- snprintf(RequestNames[i], RN_SIZE, "Request#%d", i);
- }
- }
- /* fprintf(stderr, "%d: %s\n", i, RequestNames[i]); */
- }
-}
-
-static void FreeRequestNames(void)
-{
- int i;
-
- for (i = 0; i < 256; i++) {
- if (RequestNames[i] != 0) {
- free(RequestNames[i]);
- RequestNames[i] = 0;
- }
- }
-}
-
-#endif
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index f214ef5ad..2979c6424 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -65,6 +65,7 @@ Equipment Corporation.
#include "dixfontstr.h"
#include "closestr.h"
#include "dixfont.h"
+#include "xace.h"
#ifdef DEBUG
#include <stdio.h>
@@ -833,6 +834,10 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
if (length > XLFDMAXFONTNAMELEN)
return BadAlloc;
+ i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
+ if (i != Success)
+ return i;
+
if (!(c = (LFclosurePtr) xalloc(sizeof *c)))
return BadAlloc;
c->fpe_list = (FontPathElementPtr *)
@@ -1105,6 +1110,10 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
if (length > XLFDMAXFONTNAMELEN)
return BadAlloc;
+ i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
+ if (i != Success)
+ return i;
+
if (!(c = (LFWIclosurePtr) xalloc(sizeof *c)))
goto badAlloc;
c->fpe_list = (FontPathElementPtr *)
@@ -1771,7 +1780,9 @@ bail:
int
SetFontPath(ClientPtr client, int npaths, unsigned char *paths, int *error)
{
- int err = Success;
+ int err = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
+ if (err != Success)
+ return err;
if (npaths == 0) {
if (SetDefaultFontPath(defaultFontPath) != Success)
@@ -1823,14 +1834,18 @@ SetDefaultFontPath(char *path)
return err;
}
-unsigned char *
-GetFontPath(int *count, int *length)
+int
+GetFontPath(ClientPtr client, int *count, int *length, unsigned char **result)
{
int i;
unsigned char *c;
int len;
FontPathElementPtr fpe;
+ i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
+ if (i != Success)
+ return i;
+
len = 0;
for (i = 0; i < num_fpes; i++) {
fpe = font_path_elements[i];
@@ -1838,7 +1853,7 @@ GetFontPath(int *count, int *length)
}
font_path_string = (unsigned char *) xrealloc(font_path_string, len);
if (!font_path_string)
- return NULL;
+ return BadAlloc;
c = font_path_string;
*length = 0;
@@ -1850,7 +1865,8 @@ GetFontPath(int *count, int *length)
c += fpe->name_length;
}
*count = num_fpes;
- return font_path_string;
+ *result = font_path_string;
+ return Success;
}
_X_EXPORT int
diff --git a/dix/dixutils.c b/dix/dixutils.c
index c1e30ff18..786f4e335 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -208,34 +208,23 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client,
Mask type, Mask access)
{
DrawablePtr pTmp;
- RESTYPE rtype;
+ int rc;
+
*pDraw = NULL;
client->errorValue = id;
if (id == INVALID)
return BadDrawable;
- if (id == client->lastDrawableID) {
- pTmp = client->lastDrawable;
-
- /* an access check is required for cached drawables */
- rtype = (type & M_WINDOW) ? RT_WINDOW : RT_PIXMAP;
- if (!XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, access, pTmp))
- return BadDrawable;
- } else
- pTmp = (DrawablePtr)SecurityLookupIDByClass(client, id, RC_DRAWABLE,
- access);
- if (!pTmp)
+ rc = dixLookupResource((pointer *)&pTmp, id, RC_DRAWABLE, client, access);
+
+ if (rc == BadValue)
return BadDrawable;
+ if (rc != Success)
+ return rc;
if (!((1 << pTmp->type) & (type ? type : M_DRAWABLE)))
return BadMatch;
- if (type & M_DRAWABLE) {
- client->lastDrawable = pTmp;
- client->lastDrawableID = id;
- client->lastGCID = INVALID;
- client->lastGC = (GCPtr)NULL;
- }
*pDraw = pTmp;
return Success;
}
@@ -264,75 +253,28 @@ dixLookupGC(GCPtr *pGC, XID id, ClientPtr client, Mask access)
_X_EXPORT int
dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
{
- pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY,
- access);
- int clientIndex = CLIENT_ID(rid);
- client->errorValue = rid;
-
- if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) {
- *pClient = clients[clientIndex];
- return Success;
- }
- *pClient = NULL;
- return BadValue;
-}
-
-/*
- * These are deprecated compatibility functions and will be removed soon!
- * Please use the new dixLookup*() functions above.
- */
-_X_EXPORT _X_DEPRECATED WindowPtr
-SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode)
-{
- WindowPtr pWin;
- int i = dixLookupWindow(&pWin, id, client, access_mode);
- static int warn = 1;
- if (warn-- > 0)
- ErrorF("Warning: LookupWindow()/SecurityLookupWindow() "
- "are deprecated. Please convert your driver/module "
- "to use dixLookupWindow().\n");
- return (i == Success) ? pWin : NULL;
-}
+ pointer pRes;
+ int rc = BadValue, clientIndex = CLIENT_ID(rid);
-_X_EXPORT _X_DEPRECATED WindowPtr
-LookupWindow(XID id, ClientPtr client)
-{
- return SecurityLookupWindow(id, client, DixUnknownAccess);
-}
+ if (!clientIndex || !clients[clientIndex] || (rid & SERVER_BIT))
+ goto bad;
-_X_EXPORT _X_DEPRECATED pointer
-SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode)
-{
- DrawablePtr pDraw;
- int i = dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
- static int warn = 1;
- if (warn-- > 0)
- ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() "
- "are deprecated. Please convert your driver/module "
- "to use dixLookupDrawable().\n");
- return (i == Success) ? pDraw : NULL;
-}
+ rc = dixLookupResource(&pRes, rid, RC_ANY, client, DixGetAttrAccess);
+ if (rc != Success)
+ goto bad;
-_X_EXPORT _X_DEPRECATED pointer
-LookupDrawable(XID id, ClientPtr client)
-{
- return SecurityLookupDrawable(id, client, DixUnknownAccess);
-}
+ rc = XaceHook(XACE_CLIENT_ACCESS, client, clients[clientIndex], access);
+ if (rc != Success)
+ goto bad;
-_X_EXPORT _X_DEPRECATED ClientPtr
-LookupClient(XID id, ClientPtr client)
-{
- ClientPtr pClient;
- int i = dixLookupClient(&pClient, id, client, DixUnknownAccess);
- static int warn = 1;
- if (warn-- > 0)
- ErrorF("Warning: LookupClient() is deprecated. Please convert your "
- "driver/module to use dixLookupClient().\n");
- return (i == Success) ? pClient : NULL;
+ *pClient = clients[clientIndex];
+ return Success;
+bad:
+ client->errorValue = rid;
+ *pClient = NULL;
+ return rc;
}
-/* end deprecated functions */
-
int
AlterSaveSetForClient(ClientPtr client, WindowPtr pWin, unsigned mode,
Bool toRoot, Bool remap)
diff --git a/dix/events.c b/dix/events.c
index 85f42b31e..15aa16ed6 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1754,8 +1754,10 @@ DeliverEventsToWindow(WindowPtr pWin, xEvent *pEvents, int count,
if (filter != CantBeFiltered &&
!((wOtherEventMasks(pWin)|pWin->eventMask) & filter))
return 0;
- if ( (attempt = TryClientEvents(wClient(pWin), pEvents, count,
- pWin->eventMask, filter, grab)) )
+ if (XaceHook(XACE_RECEIVE_ACCESS, wClient(pWin), pWin, pEvents, count))
+ /* do nothing */;
+ else if ( (attempt = TryClientEvents(wClient(pWin), pEvents, count,
+ pWin->eventMask, filter, grab)) )
{
if (attempt > 0)
{
@@ -1782,7 +1784,10 @@ DeliverEventsToWindow(WindowPtr pWin, xEvent *pEvents, int count,
other = (InputClients *)wOtherClients(pWin);
for (; other; other = other->next)
{
- if ( (attempt = TryClientEvents(rClient(other), pEvents, count,
+ if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), pWin, pEvents,
+ count))
+ /* do nothing */;
+ else if ( (attempt = TryClientEvents(rClient(other), pEvents, count,
other->mask[mskidx], filter, grab)) )
{
if (attempt > 0)
@@ -1879,6 +1884,8 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
return XineramaTryClientEventsResult(
wClient(pWin), NullGrab, pWin->eventMask, filter);
#endif
+ if (XaceHook(XACE_RECEIVE_ACCESS, wClient(pWin), pWin, pEvents, count))
+ return 1; /* don't send, but pretend we did */
return TryClientEvents(wClient(pWin), pEvents, count,
pWin->eventMask, filter, NullGrab);
}
@@ -1893,6 +1900,9 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
return XineramaTryClientEventsResult(
rClient(other), NullGrab, other->mask, filter);
#endif
+ if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), pWin, pEvents,
+ count))
+ return 1; /* don't send, but pretend we did */
return TryClientEvents(rClient(other), pEvents, count,
other->mask, filter, NullGrab);
}
@@ -1987,6 +1997,9 @@ DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab,
Mask filter = filters[type];
int deliveries = 0;
+ if (XaceHook(XACE_SEND_ACCESS, NULL, dev, pWin, xE, count))
+ return 0;
+
if (type & EXTENSION_EVENT_BASE)
{
OtherInputMasks *inputMasks;
@@ -2579,18 +2592,24 @@ ProcWarpPointer(ClientPtr client)
WindowPtr dest = NULL;
int x, y, rc;
ScreenPtr newScreen;
-
+ DeviceIntPtr dev;
REQUEST(xWarpPointerReq);
-
REQUEST_SIZE_MATCH(xWarpPointerReq);
+ for (dev = inputInfo.devices; dev; dev = dev->next) {
+ if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixWriteAccess);
+ if (rc != Success)
+ return rc;
+ }
+ }
#ifdef PANORAMIX
if(!noPanoramiXExtension)
return XineramaWarpPointer(client);
#endif
if (stuff->dstWid != None) {
- rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess);
+ rc = dixLookupWindow(&dest, stuff->dstWid, client, DixGetAttrAccess);
if (rc != Success)
return rc;
}
@@ -2603,7 +2622,7 @@ ProcWarpPointer(ClientPtr client)
XID winID = stuff->srcWid;
WindowPtr source;
- rc = dixLookupWindow(&source, winID, client, DixReadAccess);
+ rc = dixLookupWindow(&source, winID, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -2745,8 +2764,6 @@ CheckPassiveGrabsOnWindow(
(grab->confineTo->realized &&
BorderSizeNotEmpty(grab->confineTo))))
{
- if (!XaceHook(XACE_DEVICE_ACCESS, wClient(pWin), device, FALSE))
- return FALSE;
#ifdef XKB
if (!noXkbExtension) {
XE_KBPTR.state &= 0x1f00;
@@ -2880,6 +2897,8 @@ DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count)
if (DeliverDeviceEvents(window, xE, NullGrab, focus, keybd, count))
return;
}
+ if (XaceHook(XACE_SEND_ACCESS, NULL, keybd, focus, xE, count))
+ return;
/* just deliver it to the focus window */
FixUpEventFromWindow(xE, focus, None, FALSE);
if (xE->u.u.type & EXTENSION_EVENT_BASE)
@@ -2929,9 +2948,14 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
if (!deliveries)
{
FixUpEventFromWindow(xE, grab->window, None, TRUE);
- deliveries = TryClientEvents(rClient(grab), xE, count,
- (Mask)grab->eventMask,
- filters[xE->u.u.type], grab);
+ if (XaceHook(XACE_SEND_ACCESS, 0, thisDev, grab->window, xE, count) ||
+ XaceHook(XACE_RECEIVE_ACCESS, rClient(grab), grab->window, xE,
+ count))
+ deliveries = 1; /* don't send, but pretend we did */
+ else
+ 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
@@ -3304,6 +3328,8 @@ ProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count)
#define AtMostOneClient \
(SubstructureRedirectMask | ResizeRedirectMask | ButtonPressMask)
+#define ManagerMask \
+ (SubstructureRedirectMask | ResizeRedirectMask)
/**
* Recalculate which events may be deliverable for the given window.
@@ -3392,12 +3418,20 @@ EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask)
{
Mask check;
OtherClients * others;
+ int rc;
if (mask & ~AllEventMasks)
{
client->errorValue = mask;
return BadValue;
}
+ check = (mask & ManagerMask);
+ if (check) {
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id,
+ RT_WINDOW, pWin, RT_NONE, NULL, DixManageAccess);
+ if (rc != Success)
+ return rc;
+ }
check = (mask & AtMostOneClient);
if (check & (pWin->eventMask|wOtherEventMasks(pWin)))
{ /* It is illegal for two different
@@ -3599,10 +3633,10 @@ EnterLeaveEvent(
xKeymapEvent ke;
ClientPtr client = grab ? rClient(grab)
: clients[CLIENT_ID(pWin->drawable.id)];
- if (XaceHook(XACE_DEVICE_ACCESS, client, keybd, FALSE))
- memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31);
- else
+ if (XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess))
bzero((char *)&ke.map[0], 31);
+ else
+ memmove((char *)&ke.map[0], (char *)&keybd->key->down[1], 31);
ke.type = KeymapNotify;
if (grab)
@@ -3706,10 +3740,10 @@ FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
{
xKeymapEvent ke;
ClientPtr client = clients[CLIENT_ID(pWin->drawable.id)];
- if (XaceHook(XACE_DEVICE_ACCESS, client, dev, FALSE))
- memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31);
- else
+ if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess))
bzero((char *)&ke.map[0], 31);
+ else
+ memmove((char *)&ke.map[0], (char *)&dev->key->down[1], 31);
ke.type = KeymapNotify;
(void)DeliverEventsToWindow(pWin, (xEvent *)&ke, 1,
@@ -3934,7 +3968,7 @@ SetInputFocus(
else if ((focusID == FollowKeyboard) && followOK)
focusWin = inputInfo.keyboard->focus->win;
else {
- rc = dixLookupWindow(&focusWin, focusID, client, DixReadAccess);
+ rc = dixLookupWindow(&focusWin, focusID, client, DixSetAttrAccess);
if (rc != Success)
return rc;
/* It is a match error to try to set the input focus to an
@@ -3942,6 +3976,10 @@ SetInputFocus(
if(!focusWin->realized)
return(BadMatch);
}
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixSetFocusAccess);
+ if (rc != Success)
+ return Success;
+
focus = dev->focus;
if ((CompareTimeStamps(time, currentTime) == LATER) ||
(CompareTimeStamps(time, focus->time) == EARLIER))
@@ -3994,9 +4032,6 @@ ProcSetInputFocus(client)
REQUEST_SIZE_MATCH(xSetInputFocusReq);
- if (!XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, TRUE))
- return Success;
-
return SetInputFocus(client, inputInfo.keyboard, stuff->focus,
stuff->revertTo, stuff->time, FALSE);
}
@@ -4011,10 +4046,16 @@ int
ProcGetInputFocus(ClientPtr client)
{
xGetInputFocusReply rep;
- /* REQUEST(xReq); */
FocusClassPtr focus = inputInfo.keyboard->focus;
-
+ int rc;
+ /* REQUEST(xReq); */
REQUEST_SIZE_MATCH(xReq);
+
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard,
+ DixGetFocusAccess);
+ if (rc != Success)
+ return rc;
+
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@@ -4044,6 +4085,7 @@ ProcGrabPointer(ClientPtr client)
CursorPtr cursor, oldCursor;
REQUEST(xGrabPointerReq);
TimeStamp time;
+ Mask access_mode = DixGrabAccess;
int rc;
REQUEST_SIZE_MATCH(xGrabPointerReq);
@@ -4070,7 +4112,7 @@ ProcGrabPointer(ClientPtr client)
client->errorValue = stuff->eventMask;
return BadValue;
}
- rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (stuff->confineTo == None)
@@ -4078,7 +4120,7 @@ ProcGrabPointer(ClientPtr client)
else
{
rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
- DixReadAccess);
+ DixSetAttrAccess);
if (rc != Success)
return rc;
}
@@ -4086,14 +4128,22 @@ ProcGrabPointer(ClientPtr client)
cursor = NullCursor;
else
{
- cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
- RT_CURSOR, DixReadAccess);
- if (!cursor)
+ rc = dixLookupResource((pointer *)&cursor, stuff->cursor, RT_CURSOR,
+ client, DixUseAccess);
+ if (rc != Success)
{
client->errorValue = stuff->cursor;
- return BadCursor;
+ return (rc == BadValue) ? BadCursor : rc;
}
+ access_mode |= DixForceAccess;
}
+ if (stuff->pointerMode == GrabModeSync ||
+ stuff->keyboardMode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, device, access_mode);
+ if (rc != Success)
+ return rc;
+
/* at this point, some sort of reply is guaranteed. */
time = ClientTimeToServerTime(stuff->time);
rep.type = X_Reply;
@@ -4168,12 +4218,12 @@ ProcChangeActivePointerGrab(ClientPtr client)
newCursor = NullCursor;
else
{
- newCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
- RT_CURSOR, DixReadAccess);
- if (!newCursor)
+ int rc = dixLookupResource((pointer *)&newCursor, stuff->cursor,
+ RT_CURSOR, client, DixUseAccess);
+ if (rc != Success)
{
client->errorValue = stuff->cursor;
- return BadCursor;
+ return (rc == BadValue) ? BadCursor : rc;
}
}
if (!grab)
@@ -4245,6 +4295,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
WindowPtr pWin;
GrabPtr grab;
TimeStamp time;
+ Mask access_mode = DixGrabAccess;
int rc;
UpdateCurrentTime();
@@ -4263,9 +4314,16 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
client->errorValue = ownerEvents;
return BadValue;
}
- rc = dixLookupWindow(&pWin, grabWindow, client, DixReadAccess);
+
+ rc = dixLookupWindow(&pWin, grabWindow, client, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+ if (this_mode == GrabModeSync || other_mode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc != Success)
return rc;
+
time = ClientTimeToServerTime(ctime);
grab = dev->grab;
if (grab && !SameClient(grab, client))
@@ -4309,15 +4367,10 @@ ProcGrabKeyboard(ClientPtr client)
REQUEST_SIZE_MATCH(xGrabKeyboardReq);
- if (XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, TRUE))
- result = GrabDevice(client, inputInfo.keyboard, stuff->keyboardMode,
- stuff->pointerMode, stuff->grabWindow,
- stuff->ownerEvents, stuff->time,
- KeyPressMask | KeyReleaseMask, &rep.status);
- else {
- result = Success;
- rep.status = AlreadyGrabbed;
- }
+ result = GrabDevice(client, inputInfo.keyboard, stuff->keyboardMode,
+ stuff->pointerMode, stuff->grabWindow,
+ stuff->ownerEvents, stuff->time,
+ KeyPressMask | KeyReleaseMask, &rep.status);
if (result != Success)
return result;
@@ -4362,14 +4415,18 @@ ProcQueryPointer(ClientPtr client)
{
xQueryPointerReply rep;
WindowPtr pWin, t;
- REQUEST(xResourceReq);
DeviceIntPtr mouse = inputInfo.pointer;
int rc;
-
+ REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
if (rc != Success)
return rc;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess);
+ if (rc != Success)
+ return rc;
+
if (mouse->valuator->motionHintWindow)
MaybeStopHint(mouse, client);
rep.type = X_Reply;
@@ -4542,7 +4599,7 @@ ProcSendEvent(ClientPtr client)
effectiveFocus = pWin = inputFocus;
}
else
- dixLookupWindow(&pWin, stuff->destination, client, DixReadAccess);
+ dixLookupWindow(&pWin, stuff->destination, client, DixSendAccess);
if (!pWin)
return BadWindow;
@@ -4556,6 +4613,9 @@ ProcSendEvent(ClientPtr client)
{
for (;pWin; pWin = pWin->parent)
{
+ if (XaceHook(XACE_SEND_ACCESS, client, NULL, pWin,
+ &stuff->event, 1))
+ return Success;
if (DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
NullGrab, 0))
return Success;
@@ -4566,7 +4626,7 @@ ProcSendEvent(ClientPtr client)
break;
}
}
- else
+ else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, &stuff->event, 1))
(void)DeliverEventsToWindow(pWin, &stuff->event, 1, stuff->eventMask,
NullGrab, 0);
return Success;
@@ -4666,7 +4726,7 @@ ProcGrabKey(ClientPtr client)
client->errorValue = stuff->modifiers;
return BadValue;
}
- rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
@@ -4677,7 +4737,7 @@ ProcGrabKey(ClientPtr client)
NullWindow, NullCursor);
if (!grab)
return BadAlloc;
- return AddPassiveGrabToList(grab);
+ return AddPassiveGrabToList(client, grab);
}
@@ -4694,6 +4754,7 @@ ProcGrabButton(ClientPtr client)
REQUEST(xGrabButtonReq);
CursorPtr cursor;
GrabPtr grab;
+ Mask access_mode = DixGrabAccess;
int rc;
REQUEST_SIZE_MATCH(xGrabButtonReq);
@@ -4725,14 +4786,14 @@ ProcGrabButton(ClientPtr client)
client->errorValue = stuff->eventMask;
return BadValue;
}
- rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;
if (stuff->confineTo == None)
confineTo = NullWindow;
else {
rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
- DixReadAccess);
+ DixSetAttrAccess);
if (rc != Success)
return rc;
}
@@ -4740,15 +4801,22 @@ ProcGrabButton(ClientPtr client)
cursor = NullCursor;
else
{
- cursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
- RT_CURSOR, DixReadAccess);
+ rc = dixLookupResource((pointer *)&cursor, stuff->cursor, RT_CURSOR,
+ client, DixUseAccess);
+ if (rc != Success)
if (!cursor)
{
client->errorValue = stuff->cursor;
- return BadCursor;
+ return (rc == BadValue) ? BadCursor : rc;
}
+ access_mode |= DixForceAccess;
}
-
+ if (stuff->pointerMode == GrabModeSync ||
+ stuff->keyboardMode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.pointer, access_mode);
+ if (rc != Success)
+ return rc;
grab = CreateGrab(client->index, inputInfo.pointer, pWin,
(Mask)stuff->eventMask, (Bool)stuff->ownerEvents,
@@ -4757,7 +4825,7 @@ ProcGrabButton(ClientPtr client)
stuff->button, confineTo, cursor);
if (!grab)
return BadAlloc;
- return AddPassiveGrabToList(grab);
+ return AddPassiveGrabToList(client, grab);
}
/**
@@ -4943,18 +5011,18 @@ int
ProcRecolorCursor(ClientPtr client)
{
CursorPtr pCursor;
- int nscr;
+ int rc, nscr;
ScreenPtr pscr;
Bool displayed;
REQUEST(xRecolorCursorReq);
REQUEST_SIZE_MATCH(xRecolorCursorReq);
- pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
- RT_CURSOR, DixWriteAccess);
- if ( !pCursor)
+ rc = dixLookupResource((pointer *)&pCursor, stuff->cursor, RT_CURSOR,
+ client, DixWriteAccess);
+ if (rc != Success)
{
client->errorValue = stuff->cursor;
- return (BadCursor);
+ return (rc == BadValue) ? BadCursor : rc;
}
pCursor->foreRed = stuff->foreRed;
diff --git a/dix/extension.c b/dix/extension.c
index 282d60ab7..9740c1b50 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -59,6 +59,8 @@ SOFTWARE.
#include "gcstruct.h"
#include "scrnintstr.h"
#include "dispatch.h"
+#include "privates.h"
+#include "registry.h"
#include "xace.h"
#define EXTENSION_BASE 128
@@ -72,39 +74,6 @@ int lastEvent = EXTENSION_EVENT_BASE;
static int lastError = FirstExtensionError;
static unsigned int NumExtensions = 0;
-extern int extensionPrivateLen;
-extern unsigned *extensionPrivateSizes;
-extern unsigned totalExtensionSize;
-
-static void
-InitExtensionPrivates(ExtensionEntry *ext)
-{
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int i;
-
- if (totalExtensionSize == sizeof(ExtensionEntry))
- ppriv = (DevUnion *)NULL;
- else
- ppriv = (DevUnion *)(ext + 1);
-
- ext->devPrivates = ppriv;
- sizes = extensionPrivateSizes;
- ptr = (char *)(ppriv + extensionPrivateLen);
- for (i = extensionPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
-}
-
_X_EXPORT ExtensionEntry *
AddExtension(char *name, int NumEvents, int NumErrors,
int (*MainProc)(ClientPtr c1),
@@ -121,14 +90,13 @@ AddExtension(char *name, int NumEvents, int NumErrors,
(unsigned)(lastError + NumErrors > LAST_ERROR))
return((ExtensionEntry *) NULL);
- ext = (ExtensionEntry *) xalloc(totalExtensionSize);
+ ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry));
if (!ext)
return((ExtensionEntry *) NULL);
- bzero(ext, totalExtensionSize);
- InitExtensionPrivates(ext);
ext->name = (char *)xalloc(strlen(name) + 1);
ext->num_aliases = 0;
ext->aliases = (char **)NULL;
+ ext->devPrivates = NULL;
if (!ext->name)
{
xfree(ext);
@@ -176,6 +144,7 @@ AddExtension(char *name, int NumEvents, int NumErrors,
ext->errorLast = 0;
}
+ RegisterExtensionNames(ext);
return(ext);
}
@@ -251,14 +220,6 @@ GetExtensionEntry(int major)
return extensions[major];
}
-_X_EXPORT void
-DeclareExtensionSecurity(char *extname, Bool secure)
-{
- int i = FindExtension(extname, strlen(extname));
- if (i >= 0)
- XaceHook(XACE_DECLARE_EXT_SECURE, extensions[i], secure);
-}
-
_X_EXPORT unsigned short
StandardMinorOpcode(ClientPtr client)
{
@@ -292,6 +253,7 @@ CloseDownExtensions(void)
for (j = extensions[i]->num_aliases; --j >= 0;)
xfree(extensions[i]->aliases[j]);
xfree(extensions[i]->aliases);
+ dixFreePrivates(extensions[i]->devPrivates);
xfree(extensions[i]);
}
xfree(extensions);
@@ -319,7 +281,7 @@ ProcQueryExtension(ClientPtr client)
else
{
i = FindExtension((char *)&stuff[1], stuff->nbytes);
- if (i < 0 || !XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
+ if (i < 0 || XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
reply.present = xFalse;
else
{
@@ -355,7 +317,7 @@ ProcListExtensions(ClientPtr client)
for (i=0; i<NumExtensions; i++)
{
/* call callbacks to find out whether to show extension */
- if (!XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
+ if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
continue;
total_length += strlen(extensions[i]->name) + 1;
@@ -370,7 +332,7 @@ ProcListExtensions(ClientPtr client)
for (i=0; i<NumExtensions; i++)
{
int len;
- if (!XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
+ if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
continue;
*bufptr++ = len = strlen(extensions[i]->name);
@@ -392,17 +354,3 @@ ProcListExtensions(ClientPtr client)
}
return(client->noClientException);
}
-
-#ifdef XSERVER_DTRACE
-void LoadExtensionNames(char **RequestNames) {
- int i;
-
- for (i=0; i<NumExtensions; i++) {
- int r = extensions[i]->base;
-
- if (RequestNames[r] == NULL) {
- RequestNames[r] = strdup(extensions[i]->name);
- }
- }
-}
-#endif
diff --git a/dix/gc.c b/dix/gc.c
index 5dbb6bf09..83f48d4e3 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -61,7 +61,9 @@ SOFTWARE.
#include "scrnintstr.h"
#include "region.h"
+#include "privates.h"
#include "dix.h"
+#include "xace.h"
#include <assert.h>
extern XID clientErrorValue;
@@ -147,7 +149,7 @@ _X_EXPORT int
dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr pUnion)
{
BITS32 index2;
- int error = 0;
+ int rc, error = 0;
PixmapPtr pPixmap;
BITS32 maskQ;
@@ -266,14 +268,15 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
if (pUnion)
{
NEXT_PTR(PixmapPtr, pPixmap);
+ rc = Success;
}
else
{
NEXTVAL(XID, newpix);
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
- newpix, RT_PIXMAP, DixReadAccess);
+ rc = dixLookupResource((pointer *)&pPixmap, newpix,
+ RT_PIXMAP, client, DixReadAccess);
}
- if (pPixmap)
+ if (rc == Success)
{
if ((pPixmap->drawable.depth != pGC->depth) ||
(pPixmap->drawable.pScreen != pGC->pScreen))
@@ -292,7 +295,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
else
{
clientErrorValue = newpix;
- error = BadPixmap;
+ error = (rc == BadValue) ? BadPixmap : rc;
}
break;
}
@@ -302,14 +305,15 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
if (pUnion)
{
NEXT_PTR(PixmapPtr, pPixmap);
+ rc = Success;
}
else
{
NEXTVAL(XID, newstipple)
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
- newstipple, RT_PIXMAP, DixReadAccess);
+ rc = dixLookupResource((pointer *)&pPixmap, newstipple,
+ RT_PIXMAP, client, DixReadAccess);
}
- if (pPixmap)
+ if (rc == Success)
{
if ((pPixmap->drawable.depth != 1) ||
(pPixmap->drawable.pScreen != pGC->pScreen))
@@ -327,7 +331,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
else
{
clientErrorValue = newstipple;
- error = BadPixmap;
+ error = (rc == BadValue) ? BadPixmap : rc;
}
break;
}
@@ -344,14 +348,15 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
if (pUnion)
{
NEXT_PTR(FontPtr, pFont);
+ rc = Success;
}
else
{
NEXTVAL(XID, newfont)
- pFont = (FontPtr)SecurityLookupIDByType(client, newfont,
- RT_FONT, DixReadAccess);
+ rc = dixLookupResource((pointer *)&pFont, newfont,
+ RT_FONT, client, DixUseAccess);
}
- if (pFont)
+ if (rc == Success)
{
pFont->refcnt++;
if (pGC->font)
@@ -361,7 +366,7 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
else
{
clientErrorValue = newfont;
- error = BadFont;
+ error = (rc == BadValue) ? BadFont : rc;
}
break;
}
@@ -414,9 +419,15 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
clipType = CT_NONE;
pPixmap = NullPixmap;
}
- else
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
- pid, RT_PIXMAP, DixReadAccess);
+ else {
+ rc = dixLookupResource((pointer *)&pPixmap, pid,
+ RT_PIXMAP, client,
+ DixReadAccess);
+ if (rc != Success) {
+ clientErrorValue = pid;
+ error = (rc == BadValue) ? BadPixmap : rc;
+ }
+ }
}
if (pPixmap)
@@ -432,11 +443,6 @@ dixChangeGC(ClientPtr client, GC *pGC, BITS32 mask, CARD32 *pC32, ChangeGCValPtr
pPixmap->refcnt++;
}
}
- else if (!pUnion && (pid != None))
- {
- clientErrorValue = pid;
- error = BadPixmap;
- }
if(error == Success)
{
(*pGC->funcs->ChangeClip)(pGC, clipType,
@@ -567,44 +573,13 @@ BUG:
should check for failure to create default tile
*/
-
-static GCPtr
-AllocateGC(ScreenPtr pScreen)
-{
- GCPtr pGC;
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- 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;
-}
-
_X_EXPORT GCPtr
-CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus)
+CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus,
+ XID gcid, ClientPtr client)
{
GCPtr pGC;
- pGC = AllocateGC(pDrawable->pScreen);
+ pGC = (GCPtr)xalloc(sizeof(GC));
if (!pGC)
{
*pStatus = BadAlloc;
@@ -617,7 +592,7 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus)
pGC->planemask = ~0;
pGC->serialNumber = GC_CHANGE_SERIAL_BIT;
pGC->funcs = 0;
-
+ pGC->devPrivates = NULL;
pGC->fgPixel = 0;
pGC->bgPixel = 1;
pGC->lineWidth = 0;
@@ -662,6 +637,12 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus)
pGC->stipple = pGC->pScreen->PixmapPerDepth[0];
pGC->stipple->refcnt++;
+ /* security creation/labeling check */
+ *pStatus = XaceHook(XACE_RESOURCE_ACCESS, client, gcid, RT_GC, pGC,
+ RT_NONE, NULL, DixCreateAccess|DixSetAttrAccess);
+ if (*pStatus != Success)
+ goto out;
+
pGC->stateChanges = (1 << (GCLastBit+1)) - 1;
if (!(*pGC->pScreen->CreateGC)(pGC))
*pStatus = BadAlloc;
@@ -669,6 +650,8 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus)
*pStatus = ChangeGC(pGC, mask, pval);
else
*pStatus = Success;
+
+out:
if (*pStatus != Success)
{
if (!pGC->tileIsPixel && !pGC->tile.pixmap)
@@ -903,6 +886,7 @@ FreeGC(pointer value, XID gid)
(*pGC->funcs->DestroyGC) (pGC);
if (pGC->dash != DefaultDash)
xfree(pGC->dash);
+ dixFreePrivates(pGC->devPrivates);
xfree(pGC);
return(Success);
}
@@ -925,7 +909,7 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth)
{
GCPtr pGC;
- pGC = AllocateGC(pScreen);
+ pGC = (GCPtr)xalloc(sizeof(GC));
if (!pGC)
return (GCPtr)NULL;
@@ -934,7 +918,7 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth)
pGC->alu = GXcopy; /* dst <- src */
pGC->planemask = ~0;
pGC->serialNumber = 0;
-
+ pGC->devPrivates = NULL;
pGC->fgPixel = 0;
pGC->bgPixel = 1;
pGC->lineWidth = 0;
diff --git a/dix/getevents.c b/dix/getevents.c
index 3754c72f4..08744ae03 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -762,7 +762,8 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
KeyClassPtr ckeyc = inputInfo.keyboard->key;
int i = 0;
- if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr != pDev) {
+ if (pDev != dixLookupPrivate(&inputInfo.keyboard->devPrivates,
+ CoreDevicePrivateKey)) {
memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
if (ckeyc->modifierKeyMap)
xfree(ckeyc->modifierKeyMap);
@@ -806,7 +807,8 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
(ckeyc->curKeySyms.maxKeyCode -
ckeyc->curKeySyms.minKeyCode),
serverClient);
- inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+ dixSetPrivate(&inputInfo.keyboard->devPrivates, CoreDevicePrivateKey,
+ pDev);
}
}
@@ -820,8 +822,10 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
_X_EXPORT void
SwitchCorePointer(DeviceIntPtr pDev)
{
- if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr != pDev)
- inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+ if (pDev != dixLookupPrivate(&inputInfo.pointer->devPrivates,
+ CoreDevicePrivateKey))
+ dixSetPrivate(&inputInfo.pointer->devPrivates,
+ CoreDevicePrivateKey, pDev);
}
diff --git a/dix/grabs.c b/dix/grabs.c
index 70d234857..85e101c6a 100644
--- a/dix/grabs.c
+++ b/dix/grabs.c
@@ -58,6 +58,7 @@ SOFTWARE.
#include "inputstr.h"
#include "cursorstr.h"
#include "dixgrabs.h"
+#include "xace.h"
#define BITMASK(i) (((Mask)1) << ((i) & 31))
#define MASKIDX(i) ((i) >> 5)
@@ -306,9 +307,11 @@ GrabsAreIdentical(GrabPtr pFirstGrab, GrabPtr pSecondGrab)
* @return Success or X error code on failure.
*/
int
-AddPassiveGrabToList(GrabPtr pGrab)
+AddPassiveGrabToList(ClientPtr client, GrabPtr pGrab)
{
GrabPtr grab;
+ Mask access_mode = DixGrabAccess;
+ int rc;
for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next)
{
@@ -322,6 +325,12 @@ AddPassiveGrabToList(GrabPtr pGrab)
}
}
+ if (pGrab->keyboardMode == GrabModeSync||pGrab->pointerMode == GrabModeSync)
+ access_mode |= DixFreezeAccess;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, pGrab->device, access_mode);
+ if (rc != Success)
+ return rc;
+
/* Remove all grabs that match the new one exactly */
for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next)
{
diff --git a/dix/main.c b/dix/main.c
index eea7eed3e..532b32534 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -100,6 +100,8 @@ Equipment Corporation.
#include "site.h"
#include "dixfont.h"
#include "extnsionst.h"
+#include "privates.h"
+#include "registry.h"
#ifdef XPRINT
#include "DiPrint.h"
#endif
@@ -116,15 +118,12 @@ Equipment Corporation.
#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);
@@ -134,8 +133,6 @@ static
#endif
Bool CreateConnectionBlock(void);
-static void FreeScreen(ScreenPtr);
-
_X_EXPORT PaddingInfo PixmapWidthPaddingInfo[33];
int connBlockScreenStart;
@@ -355,15 +352,10 @@ main(int argc, char *argv[], char *envp[])
InitAtoms();
InitEvents();
InitGlyphCaching();
- ResetExtensionPrivates();
- ResetClientPrivates();
- ResetScreenPrivates();
- ResetWindowPrivates();
- ResetGCPrivates();
- ResetPixmapPrivates();
- ResetColormapPrivates();
+ if (!dixResetPrivates())
+ FatalError("couldn't init private data storage");
+ dixResetRegistry();
ResetFontPrivateIndex();
- ResetDevicePrivateIndex();
InitCallbackManager();
InitVisualWrap();
InitOutput(&screenInfo, argc, argv);
@@ -376,8 +368,6 @@ main(int argc, char *argv[], char *envp[])
if (screenInfo.numVideoScreens < 0)
screenInfo.numVideoScreens = screenInfo.numScreens;
InitExtensions(argc, argv);
- if (!InitClientPrivates(serverClient))
- FatalError("failed to allocate serverClient devprivates");
for (i = 0; i < screenInfo.numScreens; i++)
{
ScreenPtr pScreen = screenInfo.screens[i];
@@ -399,9 +389,9 @@ main(int argc, char *argv[], char *envp[])
FatalError("failed to initialize core devices");
InitFonts();
- if (loadableFonts) {
- SetFontPath(0, 0, (unsigned char *)defaultFontPath, &error);
- }
+ if (loadableFonts)
+ SetFontPath(serverClient, 0, (unsigned char *)defaultFontPath,
+ &error);
else {
if (SetDefaultFontPath(defaultFontPath) != Success)
ErrorF("failed to set default font path '%s'",
@@ -434,7 +424,7 @@ main(int argc, char *argv[], char *envp[])
for (i = 0; i < screenInfo.numScreens; i++)
InitRootWindow(WindowTable[i]);
DefineInitialRootWindow(WindowTable[0]);
- SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
#ifdef PANORAMIX
if (!noPanoramiXExtension) {
@@ -455,7 +445,7 @@ main(int argc, char *argv[], char *envp[])
/* Now free up whatever must be freed */
if (screenIsSaved == SCREEN_SAVER_ON)
- SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
+ dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
FreeScreenSaverTimer();
CloseDownExtensions();
@@ -478,7 +468,8 @@ main(int argc, char *argv[], char *envp[])
FreeGCperDepth(i);
FreeDefaultStipple(i);
(* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]);
- FreeScreen(screenInfo.screens[i]);
+ dixFreePrivates(screenInfo.screens[i]->devPrivates);
+ xfree(screenInfo.screens[i]);
screenInfo.numScreens = i;
}
CloseDownEvents();
@@ -488,7 +479,7 @@ main(int argc, char *argv[], char *envp[])
FreeAuditTimer();
- xfree(serverClient->devPrivates);
+ dixFreePrivates(serverClient->devPrivates);
serverClient->devPrivates = NULL;
if (dispatchException & DE_TERMINATE)
@@ -700,24 +691,8 @@ AddScreen(
if (!pScreen)
return -1;
- pScreen->devPrivates = (DevUnion *)xcalloc(sizeof(DevUnion),
- screenPrivateCount);
- if (!pScreen->devPrivates && screenPrivateCount)
- {
- xfree(pScreen);
- return -1;
- }
+ pScreen->devPrivates = NULL;
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);
- pScreen->PixmapPrivateLen = 0;
- pScreen->PixmapPrivateSizes = (unsigned *)NULL;
pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
pScreen->CreateScreenResources = 0;
@@ -770,19 +745,10 @@ AddScreen(
screenInfo.numScreens++;
if (!(*pfnInit)(i, pScreen, argc, argv))
{
- FreeScreen(pScreen);
+ dixFreePrivates(pScreen->devPrivates);
+ xfree(pScreen);
screenInfo.numScreens--;
return -1;
}
return i;
}
-
-static void
-FreeScreen(ScreenPtr pScreen)
-{
- xfree(pScreen->WindowPrivateSizes);
- xfree(pScreen->GCPrivateSizes);
- xfree(pScreen->PixmapPrivateSizes);
- xfree(pScreen->devPrivates);
- xfree(pScreen);
-}
diff --git a/dix/pixmap.c b/dix/pixmap.c
index 5b9a6a3aa..82e388cf3 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -109,11 +109,6 @@ _X_EXPORT PixmapPtr
AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
{
PixmapPtr pPixmap;
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int i;
if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
return NullPixmap;
@@ -121,27 +116,7 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
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;
- }
-
-#ifdef _XSERVER64
- if (pPixmap) {
- pPixmap->drawable.pad0 = 0;
- pPixmap->drawable.pad1 = 0;
- }
-#endif
+ pPixmap->devPrivates = NULL;
return pPixmap;
}
diff --git a/dix/privates.c b/dix/privates.c
index 246597117..e04da41b1 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -30,425 +30,218 @@ from The Open Group.
#include <dix-config.h>
#endif
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "misc.h"
-#include "os.h"
+#include <stddef.h>
#include "windowstr.h"
#include "resource.h"
-#include "dixstruct.h"
+#include "privates.h"
#include "gcstruct.h"
+#include "cursorstr.h"
#include "colormapst.h"
-#include "servermd.h"
-#include "site.h"
#include "inputstr.h"
-#include "extnsionst.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.
- */
-
-/*
- * extension private machinery
- */
-
-static int extensionPrivateCount;
-int extensionPrivateLen;
-unsigned *extensionPrivateSizes;
-unsigned totalExtensionSize;
-
-void
-ResetExtensionPrivates(void)
-{
- extensionPrivateCount = 0;
- extensionPrivateLen = 0;
- xfree(extensionPrivateSizes);
- extensionPrivateSizes = (unsigned *)NULL;
- totalExtensionSize =
- ((sizeof(ExtensionEntry) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
-}
-
-_X_EXPORT int
-AllocateExtensionPrivateIndex(void)
-{
- return extensionPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocateExtensionPrivate(int index2, unsigned amount)
-{
- unsigned oldamount;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
-
- if (index2 >= extensionPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *)xrealloc(extensionPrivateSizes,
- (index2 + 1) * sizeof(unsigned));
- if (!nsizes)
- return FALSE;
- while (extensionPrivateLen <= index2)
- {
- nsizes[extensionPrivateLen++] = 0;
- totalExtensionSize += sizeof(DevUnion);
- }
- extensionPrivateSizes = nsizes;
+typedef struct _PrivateDesc {
+ DevPrivateKey key;
+ unsigned size;
+ CallbackListPtr initfuncs;
+ CallbackListPtr deletefuncs;
+ struct _PrivateDesc *next;
+} PrivateDescRec;
+
+/* list of all allocated privates */
+static PrivateDescRec *items = NULL;
+
+static _X_INLINE PrivateDescRec *
+findItem(const DevPrivateKey key)
+{
+ PrivateDescRec *item = items;
+ while (item) {
+ if (item->key == key)
+ return item;
+ item = item->next;
}
- oldamount = extensionPrivateSizes[index2];
- if (amount > oldamount)
- {
- extensionPrivateSizes[index2] = amount;
- totalExtensionSize += (amount - oldamount);
- }
- return TRUE;
+ return NULL;
}
/*
- * client private machinery
+ * Request pre-allocated space.
*/
-
-static int clientPrivateCount;
-int clientPrivateLen;
-unsigned *clientPrivateSizes;
-unsigned totalClientSize;
-
-void
-ResetClientPrivates(void)
-{
- clientPrivateCount = 0;
- clientPrivateLen = 0;
- xfree(clientPrivateSizes);
- clientPrivateSizes = (unsigned *)NULL;
- totalClientSize =
- ((sizeof(ClientRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
-}
-
_X_EXPORT int
-AllocateClientPrivateIndex(void)
-{
- return clientPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocateClientPrivate(int index2, unsigned amount)
+dixRequestPrivate(const DevPrivateKey key, unsigned size)
{
- 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)
+ PrivateDescRec *item = findItem(key);
+ if (item) {
+ if (size > item->size)
+ item->size = size;
+ } else {
+ item = (PrivateDescRec *)xalloc(sizeof(PrivateDescRec));
+ if (!item)
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);
+ memset(item, 0, sizeof(PrivateDescRec));
+
+ /* add privates descriptor */
+ item->key = key;
+ item->size = size;
+ item->next = items;
+ items = item;
}
return TRUE;
}
/*
- * screen private machinery
- */
-
-int screenPrivateCount;
-
-void
-ResetScreenPrivates(void)
-{
- screenPrivateCount = 0;
-}
-
-/* this can be called after some screens have been created,
- * so we have to worry about resizing existing devPrivates
+ * Allocate a private and attach it to an existing object.
*/
-_X_EXPORT int
-AllocateScreenPrivateIndex(void)
-{
- 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;
+_X_EXPORT pointer *
+dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
+{
+ PrivateDescRec *item = findItem(key);
+ PrivateRec *ptr;
+ unsigned size = sizeof(PrivateRec);
+
+ if (item)
+ size += item->size;
+
+ ptr = (PrivateRec *)xcalloc(size, 1);
+ if (!ptr)
+ return NULL;
+ ptr->key = key;
+ ptr->value = (size > sizeof(PrivateRec)) ? (ptr + 1) : NULL;
+ ptr->next = *privates;
+ *privates = ptr;
+
+ /* call any init funcs and return */
+ if (item) {
+ PrivateCallbackRec calldata = { key, &ptr->value };
+ CallCallbacks(&item->initfuncs, &calldata);
}
- return idx;
+ return &ptr->value;
}
-
/*
- * window private machinery
+ * Called to free privates at object deletion time.
*/
-
-static int windowPrivateCount;
-
-void
-ResetWindowPrivates(void)
-{
- windowPrivateCount = 0;
-}
-
-_X_EXPORT int
-AllocateWindowPrivateIndex(void)
-{
- return windowPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocateWindowPrivate(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);
+_X_EXPORT void
+dixFreePrivates(PrivateRec *privates)
+{
+ PrivateRec *ptr, *next;
+ PrivateDescRec *item;
+ PrivateCallbackRec calldata;
+
+ /* first pass calls the delete callbacks */
+ for (ptr = privates; ptr; ptr = ptr->next) {
+ item = findItem(ptr->key);
+ if (item) {
+ calldata.key = ptr->key;
+ calldata.value = &ptr->value;
+ CallCallbacks(&item->deletefuncs, &calldata);
}
- pScreen->WindowPrivateSizes = nsizes;
}
- oldamount = pScreen->WindowPrivateSizes[index2];
- if (amount > oldamount)
- {
- pScreen->WindowPrivateSizes[index2] = amount;
- pScreen->totalWindowSize += (amount - oldamount);
+
+ /* second pass frees the memory */
+ ptr = privates;
+ while (ptr) {
+ next = ptr->next;
+ xfree(ptr);
+ ptr = next;
}
- return TRUE;
}
-
/*
- * gc private machinery
+ * Callback registration
*/
-
-static int gcPrivateCount;
-
-void
-ResetGCPrivates(void)
-{
- gcPrivateCount = 0;
-}
-
_X_EXPORT int
-AllocateGCPrivateIndex(void)
-{
- return gcPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocateGCPrivate(ScreenPtr pScreen, int index2, unsigned amount)
+dixRegisterPrivateInitFunc(const DevPrivateKey key,
+ CallbackProcPtr callback, pointer data)
{
- 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)
+ PrivateDescRec *item = findItem(key);
+ if (!item) {
+ if (!dixRequestPrivate(key, 0))
return FALSE;
- while (pScreen->GCPrivateLen <= index2)
- {
- nsizes[pScreen->GCPrivateLen++] = 0;
- pScreen->totalGCSize += sizeof(DevUnion);
- }
- pScreen->GCPrivateSizes = nsizes;
+ item = findItem(key);
}
- oldamount = pScreen->GCPrivateSizes[index2];
- if (amount > oldamount)
- {
- pScreen->GCPrivateSizes[index2] = amount;
- pScreen->totalGCSize += (amount - oldamount);
- }
- return TRUE;
-}
-
-
-/*
- * pixmap private machinery
- */
-static int pixmapPrivateCount;
-
-void
-ResetPixmapPrivates(void)
-{
- pixmapPrivateCount = 0;
+ return AddCallback(&item->initfuncs, callback, data);
}
_X_EXPORT int
-AllocatePixmapPrivateIndex(void)
+dixRegisterPrivateDeleteFunc(const DevPrivateKey key,
+ CallbackProcPtr callback, pointer data)
{
- return pixmapPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocatePixmapPrivate(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)
+ PrivateDescRec *item = findItem(key);
+ if (!item) {
+ if (!dixRequestPrivate(key, 0))
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);
+ item = findItem(key);
}
- pScreen->totalPixmapSize = BitmapBytePad(pScreen->totalPixmapSize * 8);
- return TRUE;
-}
-
+ return AddCallback(&item->deletefuncs, callback, data);
+}
+
+/* Table of devPrivates offsets */
+static const int offsetDefaults[] = {
+ -1, /* RT_NONE */
+ offsetof(WindowRec, devPrivates), /* RT_WINDOW */
+ offsetof(PixmapRec, devPrivates), /* RT_PIXMAP */
+ offsetof(GC, devPrivates), /* RT_GC */
+ -1, /* RT_FONT */
+ offsetof(CursorRec, devPrivates), /* RT_CURSOR */
+ offsetof(ColormapRec, devPrivates), /* RT_COLORMAP */
+ -1, /* RT_CMAPENTRY */
+ -1, /* RT_OTHERCLIENT */
+ -1 /* RT_PASSIVEGRAB */
+};
+
+static int *offsets = NULL;
+static int offsetsSize = 0;
/*
- * colormap private machinery
+ * Specify where the devPrivates field is located in a structure type
*/
-
-int colormapPrivateCount;
-
-void
-ResetColormapPrivates(void)
-{
- colormapPrivateCount = 0;
-}
-
-
_X_EXPORT int
-AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc)
+dixRegisterPrivateOffset(RESTYPE type, int offset)
{
- 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];
+ type = type & TypeMask;
- 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;
- }
+ /* resize offsets table if necessary */
+ while (type >= offsetsSize) {
+ unsigned i = offsetsSize * 2 * sizeof(int);
+ offsets = (int *)xrealloc(offsets, i);
+ if (!offsets) {
+ offsetsSize = 0;
+ return FALSE;
}
+ for (i=offsetsSize; i < 2*offsetsSize; i++)
+ offsets[i] = -1;
+ offsetsSize *= 2;
}
- return index;
+ offsets[type] = offset;
+ return TRUE;
}
-/*
- * device private machinery
- */
-
-static int devicePrivateIndex = 0;
-
_X_EXPORT int
-AllocateDevicePrivateIndex(void)
+dixLookupPrivateOffset(RESTYPE type)
{
- return devicePrivateIndex++;
+ type = type & TypeMask;
+ assert(type < offsetsSize);
+ return offsets[type];
}
-_X_EXPORT Bool
-AllocateDevicePrivate(DeviceIntPtr device, int index)
+int
+dixResetPrivates(void)
{
- 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;
- }
-}
+ PrivateDescRec *next;
-void
-ResetDevicePrivateIndex(void)
-{
- devicePrivateIndex = 0;
+ /* reset internal structures */
+ while (items) {
+ next = items->next;
+ xfree(items);
+ items = next;
+ }
+ if (offsets)
+ xfree(offsets);
+ offsetsSize = sizeof(offsetDefaults);
+ offsets = (int *)xalloc(offsetsSize);
+ offsetsSize /= sizeof(int);
+ if (!offsets)
+ return FALSE;
+ memcpy(offsets, offsetDefaults, sizeof(offsetDefaults));
+ return TRUE;
}
diff --git a/dix/property.c b/dix/property.c
index 994d3a7a5..3c0eaf1c9 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -91,6 +91,19 @@ PrintPropertys(WindowPtr pWin)
}
#endif
+static _X_INLINE PropertyPtr
+FindProperty(WindowPtr pWin, Atom propertyName)
+{
+ PropertyPtr pProp = wUserProps(pWin);
+ while (pProp)
+ {
+ if (pProp->propertyName == propertyName)
+ break;
+ pProp = pProp->next;
+ }
+ return pProp;
+}
+
static void
deliverPropertyNotifyEvent(WindowPtr pWin, int state, Atom atom)
{
@@ -116,7 +129,7 @@ ProcRotateProperties(ClientPtr client)
REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2);
UpdateCurrentTime();
- rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixSetPropAccess);
if (rc != Success)
return rc;
if (!stuff->nAtoms)
@@ -127,35 +140,29 @@ ProcRotateProperties(ClientPtr client)
return(BadAlloc);
for (i = 0; i < stuff->nAtoms; i++)
{
- char action = XaceHook(XACE_PROPERTY_ACCESS, client, pWin, atoms[i],
- DixReadAccess|DixWriteAccess);
-
- if (!ValidAtom(atoms[i]) || (XaceErrorOperation == action)) {
+ if (!ValidAtom(atoms[i])) {
xfree(props);
client->errorValue = atoms[i];
return BadAtom;
}
- if (XaceIgnoreOperation == action) {
- xfree(props);
- return Success;
- }
-
for (j = i + 1; j < stuff->nAtoms; j++)
if (atoms[j] == atoms[i])
{
xfree(props);
return BadMatch;
}
- pProp = wUserProps (pWin);
- while (pProp)
- {
- if (pProp->propertyName == atoms[i])
- goto found;
- pProp = pProp->next;
- }
- xfree(props);
- return BadMatch;
-found:
+ pProp = FindProperty(pWin, atoms[i]);
+ if (!pProp) {
+ xfree(props);
+ return BadMatch;
+ }
+ rc = XaceHook(XACE_PROPERTY_ACCESS, client, pWin, pProp,
+ DixReadAccess|DixWriteAccess);
+ if (rc != Success) {
+ xfree(props);
+ client->errorValue = atoms[i];
+ return rc;
+ }
props[i] = pProp;
}
delta = stuff->nPositions;
@@ -210,7 +217,7 @@ ProcChangeProperty(ClientPtr client)
totalSize = len * sizeInBytes;
REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize);
- err = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+ err = dixLookupWindow(&pWin, stuff->window, client, DixSetPropAccess);
if (err != Success)
return err;
if (!ValidAtom(stuff->property))
@@ -224,18 +231,9 @@ ProcChangeProperty(ClientPtr client)
return(BadAtom);
}
- switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property,
- DixWriteAccess))
- {
- case XaceErrorOperation:
- client->errorValue = stuff->property;
- return BadAtom;
- case XaceIgnoreOperation:
- return Success;
- }
-
- err = ChangeWindowProperty(pWin, stuff->property, stuff->type, (int)format,
- (int)mode, len, (pointer)&stuff[1], TRUE);
+ err = dixChangeWindowProperty(client, pWin, stuff->property, stuff->type,
+ (int)format, (int)mode, len, &stuff[1],
+ TRUE);
if (err != Success)
return err;
else
@@ -243,27 +241,20 @@ ProcChangeProperty(ClientPtr client)
}
_X_EXPORT int
-ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
- int mode, unsigned long len, pointer value,
- Bool sendevent)
+dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
+ Atom type, int format, int mode, unsigned long len,
+ pointer value, Bool sendevent)
{
PropertyPtr pProp;
- int sizeInBytes;
- int totalSize;
+ int sizeInBytes, totalSize, rc;
pointer data;
sizeInBytes = format>>3;
totalSize = len * sizeInBytes;
/* first see if property already exists */
+ pProp = FindProperty(pWin, property);
- pProp = wUserProps (pWin);
- while (pProp)
- {
- if (pProp->propertyName == property)
- break;
- pProp = pProp->next;
- }
if (!pProp) /* just add to list */
{
if (!pWin->optional && !MakeWindowOptional (pWin))
@@ -284,11 +275,26 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
if (len)
memmove((char *)data, (char *)value, totalSize);
pProp->size = len;
+ pProp->devPrivates = NULL;
+ rc = XaceHook(XACE_PROPERTY_ACCESS, pClient, pWin, pProp,
+ DixCreateAccess|DixWriteAccess);
+ if (rc != Success) {
+ xfree(data);
+ xfree(pProp);
+ pClient->errorValue = property;
+ return rc;
+ }
pProp->next = pWin->optional->userProps;
pWin->optional->userProps = pProp;
}
else
{
+ rc = XaceHook(XACE_PROPERTY_ACCESS, pClient, pWin, pProp,
+ DixWriteAccess);
+ if (rc != Success) {
+ pClient->errorValue = property;
+ return rc;
+ }
/* 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
@@ -349,10 +355,20 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
return(Success);
}
+_X_EXPORT int
+ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format,
+ int mode, unsigned long len, pointer value,
+ Bool sendevent)
+{
+ return dixChangeWindowProperty(serverClient, pWin, property, type, format,
+ mode, len, value, sendevent);
+}
+
int
-DeleteProperty(WindowPtr pWin, Atom propName)
+DeleteProperty(ClientPtr client, WindowPtr pWin, Atom propName)
{
PropertyPtr pProp, prevProp;
+ int rc;
if (!(pProp = wUserProps (pWin)))
return(Success);
@@ -366,6 +382,11 @@ DeleteProperty(WindowPtr pWin, Atom propName)
}
if (pProp)
{
+ rc = XaceHook(XACE_PROPERTY_ACCESS, client, pWin, pProp,
+ DixDestroyAccess);
+ if (rc != Success)
+ return rc;
+
if (prevProp == (PropertyPtr)NULL) /* takes care of head */
{
if (!(pWin->optional->userProps = pProp->next))
@@ -376,6 +397,7 @@ DeleteProperty(WindowPtr pWin, Atom propName)
prevProp->next = pProp->next;
}
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
+ dixFreePrivates(pProp->devPrivates);
xfree(pProp->data);
xfree(pProp);
}
@@ -392,6 +414,7 @@ DeleteAllWindowProperties(WindowPtr pWin)
{
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
pNextProp = pProp->next;
+ dixFreePrivates(pProp->devPrivates);
xfree(pProp->data);
xfree(pProp);
pProp = pNextProp;
@@ -428,16 +451,19 @@ int
ProcGetProperty(ClientPtr client)
{
PropertyPtr pProp, prevProp;
- unsigned long n, len, ind, rc;
+ unsigned long n, len, ind;
+ int rc;
WindowPtr pWin;
xGetPropertyReply reply;
- Mask access_mode = DixReadAccess;
+ Mask access_mode = DixGetPropAccess;
REQUEST(xGetPropertyReq);
REQUEST_SIZE_MATCH(xGetPropertyReq);
- if (stuff->delete)
+ if (stuff->delete) {
UpdateCurrentTime();
- rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ access_mode |= DixSetPropAccess;
+ }
+ rc = dixLookupWindow(&pWin, stuff->window, client, access_mode);
if (rc != Success)
return rc;
@@ -472,16 +498,14 @@ ProcGetProperty(ClientPtr client)
if (!pProp)
return NullPropertyReply(client, None, 0, &reply);
+ access_mode = DixReadAccess;
if (stuff->delete)
access_mode |= DixDestroyAccess;
- switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property,
- access_mode))
- {
- case XaceErrorOperation:
+
+ rc = XaceHook(XACE_PROPERTY_ACCESS, client, pWin, pProp, access_mode);
+ if (rc != Success) {
client->errorValue = stuff->property;
- return BadAtom;;
- case XaceIgnoreOperation:
- return NullPropertyReply(client, pProp->type, pProp->format, &reply);
+ return rc;
}
/* If the request type and actual type don't match. Return the
@@ -547,6 +571,7 @@ ProcGetProperty(ClientPtr client)
}
else
prevProp->next = pProp->next;
+ dixFreePrivates(pProp->devPrivates);
xfree(pProp->data);
xfree(pProp);
}
@@ -564,7 +589,7 @@ ProcListProperties(ClientPtr client)
REQUEST(xResourceReq);
REQUEST_SIZE_MATCH(xResourceReq);
- rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->id, client, DixListPropAccess);
if (rc != Success)
return rc;
@@ -608,7 +633,7 @@ ProcDeleteProperty(ClientPtr client)
REQUEST_SIZE_MATCH(xDeletePropertyReq);
UpdateCurrentTime();
- result = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+ result = dixLookupWindow(&pWin, stuff->window, client, DixSetPropAccess);
if (result != Success)
return result;
if (!ValidAtom(stuff->property))
@@ -617,17 +642,7 @@ ProcDeleteProperty(ClientPtr client)
return (BadAtom);
}
- switch (XaceHook(XACE_PROPERTY_ACCESS, client, pWin, stuff->property,
- DixDestroyAccess))
- {
- case XaceErrorOperation:
- client->errorValue = stuff->property;
- return BadAtom;;
- case XaceIgnoreOperation:
- return Success;
- }
-
- result = DeleteProperty(pWin, stuff->property);
+ result = DeleteProperty(client, pWin, stuff->property);
if (client->noClientException != Success)
return(client->noClientException);
else
diff --git a/dix/protocol.txt b/dix/protocol.txt
new file mode 100644
index 000000000..f4cdf7bbb
--- /dev/null
+++ b/dix/protocol.txt
@@ -0,0 +1,1054 @@
+# Registry of protocol names used by X Server
+# This will eventually be replaced by server-side XCB
+#
+# Format is Xnnn <extension-name>:<object-name>
+# R=Request, V=Event, E=Error
+#
+# This is a security-sensitive file, please set permissions as appropriate.
+#
+R001 Adobe-DPS-Extension:Init
+R002 Adobe-DPS-Extension:CreateContext
+R003 Adobe-DPS-Extension:CreateSpace
+R004 Adobe-DPS-Extension:GiveInput
+R005 Adobe-DPS-Extension:GetStatus
+R006 Adobe-DPS-Extension:DestroySpace
+R007 Adobe-DPS-Extension:Reset
+R008 Adobe-DPS-Extension:NotifyContext
+R009 Adobe-DPS-Extension:CreateContextFromID
+R010 Adobe-DPS-Extension:XIDFromContext
+R011 Adobe-DPS-Extension:ContextFromXID
+R012 Adobe-DPS-Extension:SetStatusMask
+R013 Adobe-DPS-Extension:CreateSecureContext
+R014 Adobe-DPS-Extension:NotifyWhenReady
+R000 Apple-DRI:QueryVersion
+R001 Apple-DRI:QueryDirectRenderingCapable
+R002 Apple-DRI:CreateSurface
+R003 Apple-DRI:DestroySurface
+R004 Apple-DRI:AuthConnection
+V000 Apple-DRI:ObsoleteEvent1
+V001 Apple-DRI:ObsoleteEvent2
+V002 Apple-DRI:ObsoleteEvent3
+V003 Apple-DRI:SurfaceNotify
+E000 Apple-DRI:ClientNotLocal
+E001 Apple-DRI:OperationNotSupported
+R000 Apple-WM:QueryVersion
+R001 Apple-WM:FrameGetRect
+R002 Apple-WM:FrameHitTest
+R003 Apple-WM:FrameDraw
+R004 Apple-WM:DisableUpdate
+R005 Apple-WM:ReenableUpdate
+R006 Apple-WM:SelectInput
+R007 Apple-WM:SetWindowMenuCheck
+R008 Apple-WM:SetFrontProcess
+R009 Apple-WM:SetWindowLevel
+R010 Apple-WM:SetCanQuit
+R011 Apple-WM:SetWindowMenu
+V000 Apple-WM:ControllerNotify
+V001 Apple-WM:ActivationNotify
+V002 Apple-WM:PasteboardNotify
+E000 Apple-WM:ClientNotLocal
+E001 Apple-WM:OperationNotSupported
+R000 BIG-REQUESTS:Enable
+R000 Composite:CompositeQueryVersion
+R001 Composite:CompositeRedirectWindow
+R002 Composite:CompositeRedirectSubwindows
+R003 Composite:CompositeUnredirectWindow
+R004 Composite:CompositeUnredirectSubwindows
+R005 Composite:CompositeCreateRegionFromBorderClip
+R006 Composite:CompositeNameWindowPixmap
+R007 Composite:CompositeGetOverlayWindow
+R008 Composite:CompositeReleaseOverlayWindow
+R000 DAMAGE:QueryVersion
+R001 DAMAGE:Create
+R002 DAMAGE:Destroy
+R003 DAMAGE:Subtract
+R004 DAMAGE:Add
+V000 DAMAGE:Notify
+E000 DAMAGE:BadDamage
+R000 DEC-XTRAP:Reset
+R001 DEC-XTRAP:GetAvailable
+R002 DEC-XTRAP:Config
+R003 DEC-XTRAP:StartTrap
+R004 DEC-XTRAP:StopTrap
+R005 DEC-XTRAP:GetCurrent
+R006 DEC-XTRAP:GetStatistics
+R007 DEC-XTRAP:SimulateXEvent
+R008 DEC-XTRAP:GetVersion
+R009 DEC-XTRAP:GetLastInpTime
+V000 DEC-XTRAP:Event
+E002 DEC-XTRAP:BadIO
+E004 DEC-XTRAP:BadStatistics
+E005 DEC-XTRAP:BadDevices
+E007 DEC-XTRAP:BadScreen
+E008 DEC-XTRAP:BadSwapReq
+R000 DMX:DMXQueryVersion
+R001 DMX:DMXGetScreenCount
+R002 DMX:DMXGetScreenInfoDEPRECATED
+R003 DMX:DMXGetWindowAttributes
+R004 DMX:DMXGetInputCount
+R005 DMX:DMXGetInputAttributes
+R006 DMX:DMXForceWindowCreationDEPRECATED
+R007 DMX:DMXReconfigureScreenDEPRECATED
+R008 DMX:DMXSync
+R009 DMX:DMXForceWindowCreation
+R010 DMX:DMXGetScreenAttributes
+R011 DMX:DMXChangeScreensAttributes
+R012 DMX:DMXAddScreen
+R013 DMX:DMXRemoveScreen
+R014 DMX:DMXGetDesktopAttributes
+R015 DMX:DMXChangeDesktopAttributes
+R016 DMX:DMXAddInput
+R017 DMX:DMXRemoveInput
+R000 DOUBLE-BUFFER:GetVersion
+R001 DOUBLE-BUFFER:AllocateBackBufferName
+R002 DOUBLE-BUFFER:DeallocateBackBufferName
+R003 DOUBLE-BUFFER:SwapBuffers
+R004 DOUBLE-BUFFER:BeginIdiom
+R005 DOUBLE-BUFFER:EndIdiom
+R006 DOUBLE-BUFFER:GetVisualInfo
+R007 DOUBLE-BUFFER:GetBackBufferAttributes
+E000 DOUBLE-BUFFER:BadBuffer
+R000 DPMS:GetVersion
+R001 DPMS:Capable
+R002 DPMS:GetTimeouts
+R003 DPMS:SetTimeouts
+R004 DPMS:Enable
+R005 DPMS:Disable
+R006 DPMS:ForceLevel
+R007 DPMS:Info
+R000 Extended-Visual-Information:QueryVersion
+R001 Extended-Visual-Information:GetVisualInfo
+R000 FontCache:QueryVersion
+R001 FontCache:GetCacheSettings
+R002 FontCache:ChangeCacheSettings
+R003 FontCache:GetCacheStatistics
+E000 FontCache:BadProtocol
+E001 FontCache:CannotAllocMemory
+R001 GLX:
+R002 GLX:Large
+R003 GLX:CreateContext
+R004 GLX:DestroyContext
+R005 GLX:MakeCurrent
+R006 GLX:IsDirect
+R007 GLX:QueryVersion
+R008 GLX:WaitGL
+R009 GLX:WaitX
+R010 GLX:CopyContext
+R011 GLX:SwapBuffers
+R012 GLX:UseXFont
+R013 GLX:CreateGLXPixmap
+R014 GLX:GetVisualConfigs
+R015 GLX:DestroyGLXPixmap
+R016 GLX:VendorPrivate
+R017 GLX:VendorPrivateWithReply
+R018 GLX:QueryExtensionsString
+R019 GLX:QueryServerString
+R020 GLX:ClientInfo
+R101 GLX:NewList
+R102 GLX:EndList
+R103 GLX:DeleteLists
+R104 GLX:GenLists
+R105 GLX:FeedbackBuffer
+R106 GLX:SelectBuffer
+R107 GLX:Mode
+R108 GLX:Finish
+R109 GLX:PixelStoref
+R110 GLX:PixelStorei
+R111 GLX:ReadPixels
+R112 GLX:GetBooleanv
+R113 GLX:GetClipPlane
+R114 GLX:GetDoublev
+R115 GLX:GetError
+R116 GLX:GetFloatv
+R117 GLX:GetIntegerv
+R118 GLX:GetLightfv
+R119 GLX:GetLightiv
+R120 GLX:GetMapdv
+R121 GLX:GetMapfv
+R122 GLX:GetMapiv
+R123 GLX:GetMaterialfv
+R124 GLX:GetMaterialiv
+R125 GLX:GetPixelfv
+R126 GLX:GetPixelMapuiv
+R127 GLX:GetPixelMapusv
+R128 GLX:GetPolygonStipple
+R129 GLX:GetString
+R130 GLX:GetTexEnvfv
+R131 GLX:GetTexEnviv
+R132 GLX:GetTexGendv
+R133 GLX:GetTexGenfv
+R134 GLX:GetTexGeniv
+R135 GLX:GetTexImage
+R136 GLX:GetTexParameterfv
+R137 GLX:GetTexParameteriv
+R138 GLX:GetTexLevelParameterfv
+R139 GLX:GetTexLevelParameteriv
+R140 GLX:IsEnabled
+R141 GLX:IsList
+R142 GLX:Flush
+E000 GLX:BadContext
+E001 GLX:BadContextState
+E002 GLX:BadDrawable
+E003 GLX:BadPixmap
+E004 GLX:BadContextTag
+E005 GLX:BadCurrentWindow
+E006 GLX:BadRenderRequest
+E007 GLX:BadLargeRequest
+E008 GLX:UnsupportedPrivateRequest
+R000 LBX:QueryVersion
+R001 LBX:StartProxy
+R002 LBX:StopProxy
+R003 LBX:Switch
+R004 LBX:NewClient
+R005 LBX:CloseClient
+R006 LBX:ModifySequence
+R007 LBX:AllowMotion
+R008 LBX:IncrementPixel
+R009 LBX:Delta
+R010 LBX:GetModifierMapping
+R011 LBX:QueryTag
+R012 LBX:InvalidateTag
+R013 LBX:PolyPoint
+R014 LBX:PolyLine
+R015 LBX:PolySegment
+R016 LBX:PolyRectangle
+R017 LBX:PolyArc
+R018 LBX:FillPoly
+R019 LBX:PolyFillRectangle
+R020 LBX:PolyFillArc
+R021 LBX:GetKeyboardMapping
+R022 LBX:QueryFont
+R023 LBX:ChangeProperty
+R024 LBX:GetProperty
+R025 LBX:TagData
+R026 LBX:CopyArea
+R027 LBX:CopyPlane
+R028 LBX:PolyText8
+R029 LBX:PolyText16
+R030 LBX:ImageText8
+R031 LBX:ImageText16
+R032 LBX:QueryExtension
+R033 LBX:PutImage
+R034 LBX:GetImage
+R035 LBX:BeginLargeRequest
+R036 LBX:LargeRequestData
+R037 LBX:EndLargeRequest
+R038 LBX:InternAtoms
+R039 LBX:GetWinAttrAndGeom
+R040 LBX:GrabCmap
+R041 LBX:ReleaseCmap
+R042 LBX:AllocColor
+R043 LBX:Sync
+E000 LBX:BadLbxClient
+R000 MIT-SCREEN-SAVER:QueryVersion
+R001 MIT-SCREEN-SAVER:QueryInfo
+R002 MIT-SCREEN-SAVER:SelectInput
+R003 MIT-SCREEN-SAVER:SetAttributes
+R004 MIT-SCREEN-SAVER:UnsetAttributes
+R005 MIT-SCREEN-SAVER:Suspend
+V000 MIT-SCREEN-SAVER:Notify
+R000 MIT-SHM:QueryVersion
+R001 MIT-SHM:Attach
+R002 MIT-SHM:Detach
+R003 MIT-SHM:PutImage
+R004 MIT-SHM:GetImage
+R005 MIT-SHM:CreatePixmap
+V000 MIT-SHM:Completion
+E000 MIT-SHM:BadShmSeg
+R000 MIT-SUNDRY-NONSTANDARD:SetBugMode
+R001 MIT-SUNDRY-NONSTANDARD:GetBugMode
+R000 Multi-Buffering:GetBufferVersion
+R001 Multi-Buffering:CreateImageBuffers
+R002 Multi-Buffering:DestroyImageBuffers
+R003 Multi-Buffering:DisplayImageBuffers
+R004 Multi-Buffering:SetMBufferAttributes
+R005 Multi-Buffering:GetMBufferAttributes
+R006 Multi-Buffering:SetBufferAttributes
+R007 Multi-Buffering:GetBufferAttributes
+R008 Multi-Buffering:GetBufferInfo
+R009 Multi-Buffering:CreateStereoWindow
+R010 Multi-Buffering:ClearImageBufferArea
+V000 Multi-Buffering:ClobberNotify
+V001 Multi-Buffering:UpdateNotify
+E000 Multi-Buffering:BadBuffer
+R000 RANDR:QueryVersion
+R001 RANDR:OldGetScreenInfo
+R002 RANDR:SetScreenConfig
+R003 RANDR:OldScreenChangeSelectInput
+R004 RANDR:SelectInput
+R005 RANDR:GetScreenInfo
+R006 RANDR:GetScreenSizeRange
+R007 RANDR:SetScreenSize
+R008 RANDR:GetScreenResources
+R009 RANDR:GetOutputInfo
+R010 RANDR:ListOutputProperties
+R011 RANDR:QueryOutputProperty
+R012 RANDR:ConfigureOutputProperty
+R013 RANDR:ChangeOutputProperty
+R014 RANDR:DeleteOutputProperty
+R015 RANDR:GetOutputProperty
+R016 RANDR:CreateMode
+R017 RANDR:DestroyMode
+R018 RANDR:AddOutputMode
+R019 RANDR:DeleteOutputMode
+R020 RANDR:GetCrtcInfo
+R021 RANDR:SetCrtcConfig
+R022 RANDR:GetCrtcGammaSize
+R023 RANDR:GetCrtcGamma
+R024 RANDR:SetCrtcGamma
+V000 RANDR:ScreenChangeNotify
+V001 RANDR:Notify
+E000 RANDR:BadRROutput
+E001 RANDR:BadRRCrtc
+E002 RANDR:BadRRMode
+R000 RECORD:QueryVersion
+R001 RECORD:CreateContext
+R002 RECORD:RegisterClients
+R003 RECORD:UnregisterClients
+R004 RECORD:GetContext
+R005 RECORD:EnableContext
+R006 RECORD:DisableContext
+R007 RECORD:FreeContext
+E000 RECORD:BadContext
+R000 RENDER:QueryVersion
+R001 RENDER:QueryPictFormats
+R002 RENDER:QueryPictIndexValues
+R003 RENDER:QueryDithers
+R004 RENDER:CreatePicture
+R005 RENDER:ChangePicture
+R006 RENDER:SetPictureClipRectangles
+R007 RENDER:FreePicture
+R008 RENDER:Composite
+R009 RENDER:Scale
+R010 RENDER:Trapezoids
+R011 RENDER:Triangles
+R012 RENDER:TriStrip
+R013 RENDER:TriFan
+R014 RENDER:ColorTrapezoids
+R015 RENDER:ColorTriangles
+R016 RENDER:Transform
+R017 RENDER:CreateGlyphSet
+R018 RENDER:ReferenceGlyphSet
+R019 RENDER:FreeGlyphSet
+R020 RENDER:AddGlyphs
+R021 RENDER:AddGlyphsFromPicture
+R022 RENDER:FreeGlyphs
+R023 RENDER:CompositeGlyphs8
+R024 RENDER:CompositeGlyphs16
+R025 RENDER:CompositeGlyphs32
+R026 RENDER:FillRectangles
+R027 RENDER:CreateCursor
+R028 RENDER:SetPictureTransform
+R029 RENDER:QueryFilters
+R030 RENDER:SetPictureFilter
+R031 RENDER:CreateAnimCursor
+R032 RENDER:AddTraps
+R033 RENDER:CreateSolidFill
+R034 RENDER:CreateLinearGradient
+R035 RENDER:CreateRadialGradient
+R036 RENDER:CreateConicalGradient
+E000 RENDER:BadPictFormat
+E001 RENDER:BadPicture
+E002 RENDER:BadPictOp
+E003 RENDER:BadGlyphSet
+E004 RENDER:BadGlyph
+R000 SECURITY:QueryVersion
+R001 SECURITY:GenerateAuthorization
+R002 SECURITY:RevokeAuthorization
+V000 SECURITY:AuthorizationRevoked
+E000 SECURITY:BadAuthorization
+E001 SECURITY:BadAuthorizationProtocol
+R000 SELinux:SELinuxQueryVersion
+R001 SELinux:SELinuxSetSelectionManager
+R002 SELinux:SELinuxGetSelectionManager
+R003 SELinux:SELinuxSetDeviceContext
+R004 SELinux:SELinuxGetDeviceContext
+R005 SELinux:SELinuxSetPropertyCreateContext
+R006 SELinux:SELinuxGetPropertyCreateContext
+R007 SELinux:SELinuxGetPropertyContext
+R008 SELinux:SELinuxSetWindowCreateContext
+R009 SELinux:SELinuxGetWindowCreateContext
+R010 SELinux:SELinuxGetWindowContext
+R000 SHAPE:QueryVersion
+R001 SHAPE:Rectangles
+R002 SHAPE:Mask
+R003 SHAPE:Combine
+R004 SHAPE:Offset
+R005 SHAPE:QueryExtents
+R006 SHAPE:SelectInput
+R007 SHAPE:InputSelected
+R008 SHAPE:GetRectangles
+V000 SHAPE:Notify
+R000 SYNC:Initialize
+R001 SYNC:ListSystemCounters
+R002 SYNC:CreateCounter
+R003 SYNC:SetCounter
+R004 SYNC:ChangeCounter
+R005 SYNC:QueryCounter
+R006 SYNC:DestroyCounter
+R007 SYNC:Await
+R008 SYNC:CreateAlarm
+R009 SYNC:ChangeAlarm
+R010 SYNC:QueryAlarm
+R011 SYNC:DestroyAlarm
+R012 SYNC:SetPriority
+R013 SYNC:GetPriority
+V000 SYNC:CounterNotify
+V001 SYNC:AlarmNotify
+E000 SYNC:BadCounter
+E001 SYNC:BadAlarm
+R000 TOG-CUP:QueryVersion
+R001 TOG-CUP:GetReservedColormapEntries
+R002 TOG-CUP:StoreColors
+R000 Windows-WM:QueryVersion
+R001 Windows-WM:FrameGetRect
+R002 Windows-WM:FrameDraw
+R003 Windows-WM:FrameSetTitle
+R004 Windows-WM:DisableUpdate
+R005 Windows-WM:ReenableUpdate
+R006 Windows-WM:SelectInput
+R007 Windows-WM:SetFrontProcess
+V000 Windows-WM:ControllerNotify
+V001 Windows-WM:ActivationNotify
+E000 Windows-WM:ClientNotLocal
+E001 Windows-WM:OperationNotSupported
+R000 X-Resource:QueryVersion
+R001 X-Resource:QueryClients
+R002 X-Resource:QueryClientResources
+R003 X-Resource:QueryClientPixmapBytes
+R001 X11:CreateWindow
+R002 X11:ChangeWindowAttributes
+R003 X11:GetWindowAttributes
+R004 X11:DestroyWindow
+R005 X11:DestroySubwindows
+R006 X11:ChangeSaveSet
+R007 X11:ReparentWindow
+R008 X11:MapWindow
+R009 X11:MapSubwindows
+R010 X11:UnmapWindow
+R011 X11:UnmapSubwindows
+R012 X11:ConfigureWindow
+R013 X11:CirculateWindow
+R014 X11:GetGeometry
+R015 X11:QueryTree
+R016 X11:InternAtom
+R017 X11:GetAtomName
+R018 X11:ChangeProperty
+R019 X11:DeleteProperty
+R020 X11:GetProperty
+R021 X11:ListProperties
+R022 X11:SetSelectionOwner
+R023 X11:GetSelectionOwner
+R024 X11:ConvertSelection
+R025 X11:SendEvent
+R026 X11:GrabPointer
+R027 X11:UngrabPointer
+R028 X11:GrabButton
+R029 X11:UngrabButton
+R030 X11:ChangeActivePointerGrab
+R031 X11:GrabKeyboard
+R032 X11:UngrabKeyboard
+R033 X11:GrabKey
+R034 X11:UngrabKey
+R035 X11:AllowEvents
+R036 X11:GrabServer
+R037 X11:UngrabServer
+R038 X11:QueryPointer
+R039 X11:GetMotionEvents
+R040 X11:TranslateCoords
+R041 X11:WarpPointer
+R042 X11:SetInputFocus
+R043 X11:GetInputFocus
+R044 X11:QueryKeymap
+R045 X11:OpenFont
+R046 X11:CloseFont
+R047 X11:QueryFont
+R048 X11:QueryTextExtents
+R049 X11:ListFonts
+R050 X11:ListFontsWithInfo
+R051 X11:SetFontPath
+R052 X11:GetFontPath
+R053 X11:CreatePixmap
+R054 X11:FreePixmap
+R055 X11:CreateGC
+R056 X11:ChangeGC
+R057 X11:CopyGC
+R058 X11:SetDashes
+R059 X11:SetClipRectangles
+R060 X11:FreeGC
+R061 X11:ClearArea
+R062 X11:CopyArea
+R063 X11:CopyPlane
+R064 X11:PolyPoint
+R065 X11:PolyLine
+R066 X11:PolySegment
+R067 X11:PolyRectangle
+R068 X11:PolyArc
+R069 X11:FillPoly
+R070 X11:PolyFillRectangle
+R071 X11:PolyFillArc
+R072 X11:PutImage
+R073 X11:GetImage
+R074 X11:PolyText8
+R075 X11:PolyText16
+R076 X11:ImageText8
+R077 X11:ImageText16
+R078 X11:CreateColormap
+R079 X11:FreeColormap
+R080 X11:CopyColormapAndFree
+R081 X11:InstallColormap
+R082 X11:UninstallColormap
+R083 X11:ListInstalledColormaps
+R084 X11:AllocColor
+R085 X11:AllocNamedColor
+R086 X11:AllocColorCells
+R087 X11:AllocColorPlanes
+R088 X11:FreeColors
+R089 X11:StoreColors
+R090 X11:StoreNamedColor
+R091 X11:QueryColors
+R092 X11:LookupColor
+R093 X11:CreateCursor
+R094 X11:CreateGlyphCursor
+R095 X11:FreeCursor
+R096 X11:RecolorCursor
+R097 X11:QueryBestSize
+R098 X11:QueryExtension
+R099 X11:ListExtensions
+R100 X11:ChangeKeyboardMapping
+R101 X11:GetKeyboardMapping
+R102 X11:ChangeKeyboardControl
+R103 X11:GetKeyboardControl
+R104 X11:Bell
+R105 X11:ChangePointerControl
+R106 X11:GetPointerControl
+R107 X11:SetScreenSaver
+R108 X11:GetScreenSaver
+R109 X11:ChangeHosts
+R110 X11:ListHosts
+R111 X11:SetAccessControl
+R112 X11:SetCloseDownMode
+R113 X11:KillClient
+R114 X11:RotateProperties
+R115 X11:ForceScreenSaver
+R116 X11:SetPointerMapping
+R117 X11:GetPointerMapping
+R118 X11:SetModifierMapping
+R119 X11:GetModifierMapping
+R127 X11:NoOperation
+V000 X11:X_Error
+V001 X11:X_Reply
+V002 X11:KeyPress
+V003 X11:KeyRelease
+V004 X11:ButtonPress
+V005 X11:ButtonRelease
+V006 X11:MotionNotify
+V007 X11:EnterNotify
+V008 X11:LeaveNotify
+V009 X11:FocusIn
+V010 X11:FocusOut
+V011 X11:KeymapNotify
+V012 X11:Expose
+V013 X11:GraphicsExpose
+V014 X11:NoExpose
+V015 X11:VisibilityNotify
+V016 X11:CreateNotify
+V017 X11:DestroyNotify
+V018 X11:UnmapNotify
+V019 X11:MapNotify
+V020 X11:MapRequest
+V021 X11:ReparentNotify
+V022 X11:ConfigureNotify
+V023 X11:ConfigureRequest
+V024 X11:GravityNotify
+V025 X11:ResizeRequest
+V026 X11:CirculateNotify
+V027 X11:CirculateRequest
+V028 X11:PropertyNotify
+V029 X11:SelectionClear
+V030 X11:SelectionRequest
+V031 X11:SelectionNotify
+V032 X11:ColormapNotify
+V033 X11:ClientMessage
+V034 X11:MappingNotify
+E000 X11:Success
+E001 X11:BadRequest
+E002 X11:BadValue
+E003 X11:BadWindow
+E004 X11:BadPixmap
+E005 X11:BadAtom
+E006 X11:BadCursor
+E007 X11:BadFont
+E008 X11:BadMatch
+E009 X11:BadDrawable
+E010 X11:BadAccess
+E011 X11:BadAlloc
+E012 X11:BadColor
+E013 X11:BadGC
+E014 X11:BadIDChoice
+E015 X11:BadName
+E016 X11:BadLength
+E017 X11:BadImplementation
+R001 X3D-PEX:GetExtensionInfo
+R002 X3D-PEX:GetEnumeratedTypeInfo
+R003 X3D-PEX:GetImpDepConstants
+R004 X3D-PEX:CreateLookupTable
+R005 X3D-PEX:CopyLookupTable
+R006 X3D-PEX:FreeLookupTable
+R007 X3D-PEX:GetTableInfo
+R008 X3D-PEX:GetPredefinedEntries
+R009 X3D-PEX:GetDefinedIndices
+R010 X3D-PEX:GetTableEntry
+R011 X3D-PEX:GetTableEntries
+R012 X3D-PEX:SetTableEntries
+R013 X3D-PEX:DeleteTableEntries
+R014 X3D-PEX:CreatePipelineContext
+R015 X3D-PEX:CopyPipelineContext
+R016 X3D-PEX:FreePipelineContext
+R017 X3D-PEX:GetPipelineContext
+R018 X3D-PEX:ChangePipelineContext
+R019 X3D-PEX:CreateRenderer
+R020 X3D-PEX:FreeRenderer
+R021 X3D-PEX:ChangeRenderer
+R022 X3D-PEX:GetRendererAttributes
+R023 X3D-PEX:GetRendererDynamics
+R024 X3D-PEX:BeginRendering
+R025 X3D-PEX:EndRendering
+R026 X3D-PEX:BeginStructure
+R027 X3D-PEX:EndStructure
+R028 X3D-PEX:OutputCommands
+R029 X3D-PEX:Network
+R030 X3D-PEX:CreateStructure
+R031 X3D-PEX:CopyStructure
+R032 X3D-PEX:DestroyStructures
+R033 X3D-PEX:GetStructureInfo
+R034 X3D-PEX:GetElementInfo
+R035 X3D-PEX:GetStructuresInNetwork
+R036 X3D-PEX:GetAncestors
+R037 X3D-PEX:GetDescendants
+R038 X3D-PEX:FetchElements
+R039 X3D-PEX:SetEditingMode
+R040 X3D-PEX:SetElementPointer
+R041 X3D-PEX:SetElementPointerAtLabel
+R042 X3D-PEX:ElementSearch
+R043 X3D-PEX:StoreElements
+R044 X3D-PEX:DeleteElements
+R045 X3D-PEX:DeleteElementsToLabel
+R046 X3D-PEX:DeleteBetweenLabels
+R047 X3D-PEX:CopyElements
+R048 X3D-PEX:ChangeStructureRefs
+R049 X3D-PEX:CreateNameSet
+R050 X3D-PEX:CopyNameSet
+R051 X3D-PEX:FreeNameSet
+R052 X3D-PEX:GetNameSet
+R053 X3D-PEX:ChangeNameSet
+R054 X3D-PEX:CreateSearchContext
+R055 X3D-PEX:CopySearchContext
+R056 X3D-PEX:FreeSearchContext
+R057 X3D-PEX:GetSearchContext
+R058 X3D-PEX:ChangeSearchContext
+R059 X3D-PEX:SearchNetwork
+R060 X3D-PEX:CreatePhigsWks
+R061 X3D-PEX:FreePhigsWks
+R062 X3D-PEX:GetWksInfo
+R063 X3D-PEX:GetDynamics
+R064 X3D-PEX:GetViewRep
+R065 X3D-PEX:RedrawAllStructures
+R066 X3D-PEX:UpdateWorkstation
+R067 X3D-PEX:RedrawClipRegion
+R068 X3D-PEX:ExecuteDeferredActions
+R069 X3D-PEX:SetViewPriority
+R070 X3D-PEX:SetDisplayUpdateMode
+R071 X3D-PEX:MapDCtoWC
+R072 X3D-PEX:MapWCtoDC
+R073 X3D-PEX:SetViewRep
+R074 X3D-PEX:SetWksWindow
+R075 X3D-PEX:SetWksViewport
+R076 X3D-PEX:SetHlhsrMode
+R077 X3D-PEX:SetWksBufferMode
+R078 X3D-PEX:PostStructure
+R079 X3D-PEX:UnpostStructure
+R080 X3D-PEX:UnpostAllStructures
+R081 X3D-PEX:GetWksPostings
+R082 X3D-PEX:GetPickDevice
+R083 X3D-PEX:ChangePickDevice
+R084 X3D-PEX:CreatePickMeasure
+R085 X3D-PEX:FreePickMeasure
+R086 X3D-PEX:GetPickMeasure
+R087 X3D-PEX:UpdatePickMeasure
+R088 X3D-PEX:OpenFont
+R089 X3D-PEX:CloseFont
+R090 X3D-PEX:QueryFont
+R091 X3D-PEX:ListFonts
+R092 X3D-PEX:ListFontsWithInfo
+R093 X3D-PEX:QueryTextExtents
+R094 X3D-PEX:MatchRenderingTargets
+R095 X3D-PEX:Escape
+R096 X3D-PEX:EscapeWithReply
+R097 X3D-PEX:Elements
+R098 X3D-PEX:AccumulateState
+R099 X3D-PEX:BeginPickOne
+R100 X3D-PEX:EndPickOne
+R101 X3D-PEX:PickOne
+R102 X3D-PEX:BeginPickAll
+R103 X3D-PEX:EndPickAll
+R104 X3D-PEX:PickAll
+E000 X3D-PEX:ColorTypeError
+E001 X3D-PEX:erStateError
+E002 X3D-PEX:FloatingPointFormatError
+E003 X3D-PEX:LabelError
+E004 X3D-PEX:LookupTableError
+E005 X3D-PEX:NameSetError
+E006 X3D-PEX:PathError
+E007 X3D-PEX:FontError
+E008 X3D-PEX:PhigsWksError
+E009 X3D-PEX:PickMeasureError
+E010 X3D-PEX:PipelineContextError
+E011 X3D-PEX:erError
+E012 X3D-PEX:SearchContextError
+E013 X3D-PEX:StructureError
+E014 X3D-PEX:OutputCommandError
+R000 XC-APPGROUP:QueryVersion
+R001 XC-APPGROUP:Create
+R002 XC-APPGROUP:Destroy
+R003 XC-APPGROUP:GetAttr
+R004 XC-APPGROUP:Query
+R005 XC-APPGROUP:CreateAssoc
+R006 XC-APPGROUP:DestroyAssoc
+E000 XC-APPGROUP:BadAppGroup
+R000 XC-MISC:GetVersion
+R001 XC-MISC:GetXIDRange
+R002 XC-MISC:GetXIDList
+R000 XEVIE:QueryVersion
+R001 XEVIE:Start
+R002 XEVIE:End
+R003 XEVIE:Send
+R004 XEVIE:SelectInput
+R000 XFIXES:QueryVersion
+R001 XFIXES:ChangeSaveSet
+R002 XFIXES:SelectSelectionInput
+R003 XFIXES:SelectCursorInput
+R004 XFIXES:GetCursorImage
+R005 XFIXES:CreateRegion
+R006 XFIXES:CreateRegionFromBitmap
+R007 XFIXES:CreateRegionFromWindow
+R008 XFIXES:CreateRegionFromGC
+R009 XFIXES:CreateRegionFromPicture
+R010 XFIXES:DestroyRegion
+R011 XFIXES:SetRegion
+R012 XFIXES:CopyRegion
+R013 XFIXES:UnionRegion
+R014 XFIXES:IntersectRegion
+R015 XFIXES:SubtractRegion
+R016 XFIXES:InvertRegion
+R017 XFIXES:TranslateRegion
+R018 XFIXES:RegionExtents
+R019 XFIXES:FetchRegion
+R020 XFIXES:SetGCClipRegion
+R021 XFIXES:SetWindowShapeRegion
+R022 XFIXES:SetPictureClipRegion
+R023 XFIXES:SetCursorName
+R024 XFIXES:GetCursorName
+R025 XFIXES:GetCursorImageAndName
+R026 XFIXES:ChangeCursor
+R027 XFIXES:ChangeCursorByName
+R028 XFIXES:ExpandRegion
+R029 XFIXES:HideCursor
+R030 XFIXES:ShowCursor
+V000 XFIXES:SelectionNotify
+V001 XFIXES:CursorNotify
+E000 XFIXES:BadRegion
+R000 XFree86-Bigfont:QueryVersion
+R001 XFree86-Bigfont:QueryFont
+R000 XFree86-DGA:QueryVersion
+R001 XFree86-DGA:GetVideoLL
+R002 XFree86-DGA:DirectVideo
+R003 XFree86-DGA:GetViewPortSize
+R004 XFree86-DGA:SetViewPort
+R005 XFree86-DGA:GetVidPage
+R006 XFree86-DGA:SetVidPage
+R007 XFree86-DGA:InstallColormap
+R008 XFree86-DGA:QueryDirectVideo
+R009 XFree86-DGA:ViewPortChanged
+R010 XFree86-DGA:Obsolete1
+R011 XFree86-DGA:Obsolete2
+R012 XFree86-DGA:QueryModes
+R013 XFree86-DGA:SetMode
+R014 XFree86-DGA:SetViewport
+R015 XFree86-DGA:InstallColormap
+R016 XFree86-DGA:SelectInput
+R017 XFree86-DGA:FillRectangle
+R018 XFree86-DGA:CopyArea
+R019 XFree86-DGA:CopyTransparentArea
+R020 XFree86-DGA:GetViewportStatus
+R021 XFree86-DGA:Sync
+R022 XFree86-DGA:OpenFramebuffer
+R023 XFree86-DGA:CloseFramebuffer
+R024 XFree86-DGA:SetClientVersion
+R025 XFree86-DGA:ChangePixmapMode
+R026 XFree86-DGA:CreateColormap
+E000 XFree86-DGA:ClientNotLocal
+E001 XFree86-DGA:NoDirectVideoMode
+E002 XFree86-DGA:ScreenNotActive
+E003 XFree86-DGA:DirectNotActivated
+E004 XFree86-DGA:OperationNotSupported
+R000 XFree86-DRI:QueryVersion
+R001 XFree86-DRI:QueryDirectRenderingCapable
+R002 XFree86-DRI:OpenConnection
+R003 XFree86-DRI:CloseConnection
+R004 XFree86-DRI:GetClientDriverName
+R005 XFree86-DRI:CreateContext
+R006 XFree86-DRI:DestroyContext
+R007 XFree86-DRI:CreateDrawable
+R008 XFree86-DRI:DestroyDrawable
+R009 XFree86-DRI:GetDrawableInfo
+R010 XFree86-DRI:GetDeviceInfo
+R011 XFree86-DRI:AuthConnection
+R012 XFree86-DRI:OpenFullScreen
+R013 XFree86-DRI:CloseFullScreen
+E000 XFree86-DRI:ClientNotLocal
+E001 XFree86-DRI:OperationNotSupported
+R000 XFree86-Misc:QueryVersion
+R001 XFree86-Misc:GetSaver
+R002 XFree86-Misc:SetSaver
+R003 XFree86-Misc:GetMouseSettings
+R004 XFree86-Misc:GetKbdSettings
+R005 XFree86-Misc:SetMouseSettings
+R006 XFree86-Misc:SetKbdSettings
+R007 XFree86-Misc:SetGrabKeysState
+R008 XFree86-Misc:SetClientVersion
+R009 XFree86-Misc:GetFilePaths
+R010 XFree86-Misc:PassMessage
+E000 XFree86-Misc:BadMouseProtocol
+E001 XFree86-Misc:BadMouseBaudRate
+E002 XFree86-Misc:BadMouseFlags
+E003 XFree86-Misc:BadMouseCombo
+E004 XFree86-Misc:BadKbdType
+E005 XFree86-Misc:ModInDevDisabled
+E006 XFree86-Misc:ModInDevClientNotLocal
+E007 XFree86-Misc:NoModule
+R000 XFree86-VidModeExtension:QueryVersion
+R001 XFree86-VidModeExtension:GetModeLine
+R002 XFree86-VidModeExtension:ModModeLine
+R003 XFree86-VidModeExtension:SwitchMode
+R004 XFree86-VidModeExtension:GetMonitor
+R005 XFree86-VidModeExtension:LockModeSwitch
+R006 XFree86-VidModeExtension:GetAllModeLines
+R007 XFree86-VidModeExtension:AddModeLine
+R008 XFree86-VidModeExtension:DeleteModeLine
+R009 XFree86-VidModeExtension:ValidateModeLine
+R010 XFree86-VidModeExtension:SwitchToMode
+R011 XFree86-VidModeExtension:GetViewPort
+R012 XFree86-VidModeExtension:SetViewPort
+R013 XFree86-VidModeExtension:GetDotClocks
+R014 XFree86-VidModeExtension:SetClientVersion
+R015 XFree86-VidModeExtension:SetGamma
+R016 XFree86-VidModeExtension:GetGamma
+R017 XFree86-VidModeExtension:GetGammaRamp
+R018 XFree86-VidModeExtension:SetGammaRamp
+R019 XFree86-VidModeExtension:GetGammaRampSize
+R020 XFree86-VidModeExtension:GetPermissions
+V000 XFree86-VidModeExtension:Notify
+E000 XFree86-VidModeExtension:BadClock
+E001 XFree86-VidModeExtension:BadHTimings
+E002 XFree86-VidModeExtension:BadVTimings
+E003 XFree86-VidModeExtension:ModeUnsuitable
+E004 XFree86-VidModeExtension:ExtensionDisabled
+E005 XFree86-VidModeExtension:ClientNotLocal
+E006 XFree86-VidModeExtension:ZoomLocked
+R001 XIE:QueryImageExtension
+R002 XIE:QueryTechniques
+R003 XIE:CreateColorList
+R004 XIE:DestroyColorList
+R005 XIE:PurgeColorList
+R006 XIE:QueryColorList
+R007 XIE:CreateLUT
+R008 XIE:DestroyLUT
+R009 XIE:CreatePhotomap
+R010 XIE:DestroyPhotomap
+R011 XIE:QueryPhotomap
+R012 XIE:CreateROI
+R013 XIE:DestroyROI
+R014 XIE:CreatePhotospace
+R015 XIE:DestroyPhotospace
+R016 XIE:ExecuteImmediate
+R017 XIE:CreatePhotoflo
+R018 XIE:DestroyPhotoflo
+R019 XIE:ExecutePhotoflo
+R020 XIE:ModifyPhotoflo
+R021 XIE:RedefinePhotoflo
+R022 XIE:PutClientData
+R023 XIE:GetClientData
+R024 XIE:QueryPhotoflo
+R025 XIE:Await
+R026 XIE:Abort
+E000 XIE:ColorListError
+E001 XIE:LUTError
+E002 XIE:PhotofloError
+E003 XIE:PhotomapError
+E004 XIE:PhotospaceError
+E005 XIE:ROIError
+E006 XIE:FloError
+R000 XINERAMA:QueryVersion
+R001 XINERAMA:GetState
+R002 XINERAMA:GetScreenCount
+R003 XINERAMA:GetScreenSize
+R004 XINERAMA:IsActive
+R005 XINERAMA:QueryScreens
+R001 XInputExtension:GetExtensionVersion
+R002 XInputExtension:ListInputDevices
+R003 XInputExtension:OpenDevice
+R004 XInputExtension:CloseDevice
+R005 XInputExtension:SetDeviceMode
+R006 XInputExtension:SelectExtensionEvent
+R007 XInputExtension:GetSelectedExtensionEvents
+R008 XInputExtension:ChangeDeviceDontPropagateList
+R009 XInputExtension:GetDeviceDontPropagageList
+R010 XInputExtension:GetDeviceMotionEvents
+R011 XInputExtension:ChangeKeyboardDevice
+R012 XInputExtension:ChangePointerDevice
+R013 XInputExtension:GrabDevice
+R014 XInputExtension:UngrabDevice
+R015 XInputExtension:GrabDeviceKey
+R016 XInputExtension:UngrabDeviceKey
+R017 XInputExtension:GrabDeviceButton
+R018 XInputExtension:UngrabDeviceButton
+R019 XInputExtension:AllowDeviceEvents
+R020 XInputExtension:GetDeviceFocus
+R021 XInputExtension:SetDeviceFocus
+R022 XInputExtension:GetFeedbackControl
+R023 XInputExtension:ChangeFeedbackControl
+R024 XInputExtension:GetDeviceKeyMapping
+R025 XInputExtension:ChangeDeviceKeyMapping
+R026 XInputExtension:GetDeviceModifierMapping
+R027 XInputExtension:SetDeviceModifierMapping
+R028 XInputExtension:GetDeviceButtonMapping
+R029 XInputExtension:SetDeviceButtonMapping
+R030 XInputExtension:QueryDeviceState
+R031 XInputExtension:SendExtensionEvent
+R032 XInputExtension:DeviceBell
+R033 XInputExtension:SetDeviceValuators
+R034 XInputExtension:GetDeviceControl
+R035 XInputExtension:ChangeDeviceControl
+V000 XInputExtension:DeviceValuator
+V001 XInputExtension:DeviceKeyPress
+V002 XInputExtension:DeviceKeyRelease
+V003 XInputExtension:DeviceButtonPress
+V004 XInputExtension:DeviceButtonRelease
+V005 XInputExtension:DeviceMotionNotify
+V006 XInputExtension:DeviceFocusIn
+V007 XInputExtension:DeviceFocusOut
+V008 XInputExtension:ProximityIn
+V009 XInputExtension:ProximityOut
+V010 XInputExtension:DeviceStateNotify
+V011 XInputExtension:DeviceMappingNotify
+V012 XInputExtension:ChangeDeviceNotify
+V013 XInputExtension:DeviceKeystateNotify
+V014 XInputExtension:DeviceButtonstateNotify
+V015 XInputExtension:DevicePresenceNotify
+E000 XInputExtension:BadDevice
+E001 XInputExtension:BadEvent
+E002 XInputExtension:BadMode
+E003 XInputExtension:DeviceBusy
+E004 XInputExtension:BadClass
+R000 XKEYBOARD:UseExtension
+R001 XKEYBOARD:SelectEvents
+R002 XKEYBOARD:Obsolete
+R003 XKEYBOARD:Bell
+R004 XKEYBOARD:GetState
+R005 XKEYBOARD:LatchLockState
+R006 XKEYBOARD:GetControls
+R007 XKEYBOARD:SetControls
+R008 XKEYBOARD:GetMap
+R009 XKEYBOARD:SetMap
+R010 XKEYBOARD:GetCompatMap
+R011 XKEYBOARD:SetCompatMap
+R012 XKEYBOARD:GetIndicatorState
+R013 XKEYBOARD:GetIndicatorMap
+R014 XKEYBOARD:SetIndicatorMap
+R015 XKEYBOARD:GetNamedIndicator
+R016 XKEYBOARD:SetNamedIndicator
+R017 XKEYBOARD:GetNames
+R018 XKEYBOARD:SetNames
+R019 XKEYBOARD:GetGeometry
+R020 XKEYBOARD:SetGeometry
+R021 XKEYBOARD:PerClientFlags
+R022 XKEYBOARD:ListComponents
+R023 XKEYBOARD:GetKbdByName
+R024 XKEYBOARD:GetDeviceInfo
+R025 XKEYBOARD:SetDeviceInfo
+R101 XKEYBOARD:SetDebuggingFlags
+V000 XKEYBOARD:EventCode
+E000 XKEYBOARD:BadKeyboard
+R000 XTEST:GetVersion
+R001 XTEST:CompareCursor
+R002 XTEST:FakeInput
+R003 XTEST:GrabControl
+R000 XVideo:QueryExtension
+R001 XVideo:QueryAdaptors
+R002 XVideo:QueryEncodings
+R003 XVideo:GrabPort
+R004 XVideo:UngrabPort
+R005 XVideo:PutVideo
+R006 XVideo:PutStill
+R007 XVideo:GetVideo
+R008 XVideo:GetStill
+R009 XVideo:StopVideo
+R010 XVideo:SelectVideoNotify
+R011 XVideo:SelectPortNotify
+R012 XVideo:QueryBestSize
+R013 XVideo:SetPortAttribute
+R014 XVideo:GetPortAttribute
+R015 XVideo:QueryPortAttributes
+R016 XVideo:ListImageFormats
+R017 XVideo:QueryImageAttributes
+R018 XVideo:PutImage
+R019 XVideo:ShmPutImage
+V000 XVideo:VideoNotify
+V001 XVideo:PortNotify
+E000 XVideo:BadPort
+E001 XVideo:BadEncoding
+E002 XVideo:BadControl
+R000 XVideo-MotionCompensation:QueryVersion
+R001 XVideo-MotionCompensation:ListSurfaceTypes
+R002 XVideo-MotionCompensation:CreateContext
+R003 XVideo-MotionCompensation:DestroyContext
+R004 XVideo-MotionCompensation:CreateSurface
+R005 XVideo-MotionCompensation:DestroySurface
+R006 XVideo-MotionCompensation:CreateSubpicture
+R007 XVideo-MotionCompensation:DestroySubpicture
+R008 XVideo-MotionCompensation:ListSubpictureTypes
+R009 XVideo-MotionCompensation:GetDRInfo
+E000 XVideo-MotionCompensation:BadContext
+E001 XVideo-MotionCompensation:BadSurface
+E002 XVideo-MotionCompensation:BadSubpicture
+R000 XpExtension:QueryVersion
+R001 XpExtension:GetPrinterList
+R002 XpExtension:CreateContext
+R003 XpExtension:SetContext
+R004 XpExtension:GetContext
+R005 XpExtension:DestroyContext
+R006 XpExtension:GetContextScreen
+R007 XpExtension:StartJob
+R008 XpExtension:EndJob
+R009 XpExtension:StartDoc
+R010 XpExtension:EndDoc
+R011 XpExtension:PutDocumentData
+R012 XpExtension:GetDocumentData
+R013 XpExtension:StartPage
+R014 XpExtension:EndPage
+R015 XpExtension:SelectInput
+R016 XpExtension:InputSelected
+R017 XpExtension:GetAttributes
+R018 XpExtension:SetAttributes
+R019 XpExtension:GetOneAttribute
+R020 XpExtension:RehashPrinterList
+R021 XpExtension:GetPageDimensions
+R022 XpExtension:QueryScreens
+R023 XpExtension:SetImageResolution
+R024 XpExtension:GetImageResolution
+V000 XpExtension:PrintNotify
+V001 XpExtension:AttributeNotify
+E000 XpExtension:BadContext
+E001 XpExtension:BadSequence
+E002 XpExtension:BadResourceID
diff --git a/dix/registry.c b/dix/registry.c
new file mode 100644
index 000000000..10fa21f84
--- /dev/null
+++ b/dix/registry.c
@@ -0,0 +1,328 @@
+/************************************************************
+
+Author: Eamon Walsh <ewalsh@epoch.ncsc.mil>
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+this permission notice appear in supporting documentation. This permission
+notice shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef XREGISTRY
+
+#include <stdlib.h>
+#include <string.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "resource.h"
+#include "registry.h"
+
+#define BASE_SIZE 16
+#define CORE "X11"
+#define FILENAME SERVER_MISC_CONFIG_PATH "/protocol.txt"
+
+#define PROT_COMMENT '#'
+#define PROT_REQUEST 'R'
+#define PROT_EVENT 'V'
+#define PROT_ERROR 'E'
+
+static FILE *fh;
+
+static char ***requests, **events, **errors, **resources;
+static unsigned nmajor, *nminor, nevent, nerror, nresource;
+
+/*
+ * File parsing routines
+ */
+static int double_size(void *p, unsigned n, unsigned size)
+{
+ char **ptr = (char **)p;
+ unsigned s, f;
+
+ if (n) {
+ s = n * size;
+ n *= 2 * size;
+ f = n;
+ } else {
+ s = 0;
+ n = f = BASE_SIZE * size;
+ }
+
+ *ptr = xrealloc(*ptr, n);
+ if (!*ptr) {
+ dixResetRegistry();
+ return FALSE;
+ }
+ memset(*ptr + s, 0, f - s);
+ return TRUE;
+}
+
+static void
+RegisterRequestName(unsigned major, unsigned minor, char *name)
+{
+ while (major >= nmajor) {
+ if (!double_size(&requests, nmajor, sizeof(char **)))
+ return;
+ if (!double_size(&nminor, nmajor, sizeof(unsigned)))
+ return;
+ nmajor = nmajor ? nmajor * 2 : BASE_SIZE;
+ }
+ while (minor >= nminor[major]) {
+ if (!double_size(requests+major, nminor[major], sizeof(char *)))
+ return;
+ nminor[major] = nminor[major] ? nminor[major] * 2 : BASE_SIZE;
+ }
+
+ free(requests[major][minor]);
+ requests[major][minor] = name;
+}
+
+static void
+RegisterEventName(unsigned event, char *name) {
+ while (event >= nevent) {
+ if (!double_size(&events, nevent, sizeof(char *)))
+ return;
+ nevent = nevent ? nevent * 2 : BASE_SIZE;
+ }
+
+ free(events[event]);
+ events[event] = name;
+}
+
+static void
+RegisterErrorName(unsigned error, char *name) {
+ while (error >= nerror) {
+ if (!double_size(&errors, nerror, sizeof(char *)))
+ return;
+ nerror = nerror ? nerror * 2 : BASE_SIZE;
+ }
+
+ free(errors[error]);
+ errors[error] = name;
+}
+
+void
+RegisterExtensionNames(ExtensionEntry *extEntry)
+{
+ char buf[256], *lineobj, *ptr;
+ unsigned offset;
+
+ if (fh == NULL)
+ return;
+
+ rewind(fh);
+
+ while (fgets(buf, sizeof(buf), fh)) {
+ ptr = strchr(buf, '\n');
+ if (ptr)
+ *ptr = 0;
+
+ switch (buf[0]) {
+ case PROT_REQUEST:
+ case PROT_EVENT:
+ case PROT_ERROR:
+ break;
+ case PROT_COMMENT:
+ case '\0':
+ continue;
+ default:
+ continue;
+ }
+
+ ptr = strchr(buf, ' ');
+ if (!ptr || ptr != buf + 4) {
+ LogMessage(X_WARNING, "Invalid line in " FILENAME ", skipping\n");
+ continue;
+ }
+ lineobj = strdup(ptr + 1);
+ if (!lineobj)
+ continue;
+
+ ptr = strchr(buf, ':');
+ if (!ptr) {
+ LogMessage(X_WARNING, "Invalid line in " FILENAME ", skipping\n");
+ continue;
+ }
+ *ptr = 0;
+
+ if (strcmp(buf + 5, extEntry->name))
+ continue;
+
+ offset = strtol(buf + 1, &ptr, 10);
+ if (offset == 0 && ptr == buf + 1) {
+ LogMessage(X_WARNING, "Invalid line in " FILENAME ", skipping\n");
+ continue;
+ }
+
+ switch(buf[0]) {
+ case PROT_REQUEST:
+ if (extEntry->base)
+ RegisterRequestName(extEntry->base, offset, lineobj);
+ else
+ RegisterRequestName(offset, 0, lineobj);
+ break;
+ case PROT_EVENT:
+ RegisterEventName(extEntry->eventBase + offset, lineobj);
+ break;
+ case PROT_ERROR:
+ RegisterErrorName(extEntry->errorBase + offset, lineobj);
+ break;
+ }
+ }
+}
+
+/*
+ * Registration functions
+ */
+
+void
+RegisterResourceName(RESTYPE resource, char *name)
+{
+ resource &= TypeMask;
+
+ while (resource >= nresource) {
+ if (!double_size(&resources, nresource, sizeof(char *)))
+ return;
+ nresource = nresource ? nresource * 2 : BASE_SIZE;
+ }
+
+ resources[resource] = name;
+}
+
+/*
+ * Lookup functions
+ */
+
+const char *
+LookupRequestName(int major, int minor)
+{
+ if (major >= nmajor)
+ return XREGISTRY_UNKNOWN;
+ if (minor >= nminor[major])
+ return XREGISTRY_UNKNOWN;
+
+ return requests[major][minor] ? requests[major][minor] : XREGISTRY_UNKNOWN;
+}
+
+const char *
+LookupMajorName(int major)
+{
+ if (major < 128) {
+ const char *retval;
+
+ if (major >= nmajor)
+ return XREGISTRY_UNKNOWN;
+ if (0 >= nminor[major])
+ return XREGISTRY_UNKNOWN;
+
+ retval = requests[major][0];
+ return retval ? retval + sizeof(CORE) : XREGISTRY_UNKNOWN;
+ } else {
+ ExtensionEntry *extEntry = GetExtensionEntry(major);
+ return extEntry ? extEntry->name : XREGISTRY_UNKNOWN;
+ }
+}
+
+const char *
+LookupEventName(int event)
+{
+ event &= 127;
+ if (event >= nevent)
+ return XREGISTRY_UNKNOWN;
+
+ return events[event] ? events[event] : XREGISTRY_UNKNOWN;
+}
+
+const char *
+LookupErrorName(int error)
+{
+ if (error >= nerror)
+ return XREGISTRY_UNKNOWN;
+
+ return errors[error] ? errors[error] : XREGISTRY_UNKNOWN;
+}
+
+const char *
+LookupResourceName(RESTYPE resource)
+{
+ resource &= TypeMask;
+ if (resource >= nresource)
+ return XREGISTRY_UNKNOWN;
+
+ return resources[resource] ? resources[resource] : XREGISTRY_UNKNOWN;
+}
+
+/*
+ * Setup and teardown
+ */
+void
+dixResetRegistry(void)
+{
+ ExtensionEntry extEntry;
+
+ /* Free all memory */
+ while (nmajor--) {
+ while (nminor[nmajor])
+ free(requests[nmajor][--nminor[nmajor]]);
+ xfree(requests[nmajor]);
+ }
+ xfree(requests);
+ xfree(nminor);
+
+ while (nevent--)
+ free(events[nevent]);
+ xfree(events);
+
+ while (nerror--)
+ free(errors[nerror]);
+ xfree(errors);
+
+ xfree(resources);
+
+ requests = NULL;
+ nminor = NULL;
+ events = NULL;
+ errors = NULL;
+ resources = NULL;
+
+ nmajor = nevent = nerror = nresource = 0;
+
+ /* Open the protocol file */
+ if (fh)
+ fclose(fh);
+ fh = fopen(FILENAME, "r");
+ if (!fh)
+ LogMessage(X_WARNING, "Failed to open protocol names file " FILENAME);
+
+ /* Add built-in resources */
+ 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");
+
+ /* Add the core protocol */
+ memset(&extEntry, 0, sizeof(extEntry));
+ extEntry.name = CORE;
+ RegisterExtensionNames(&extEntry);
+}
+
+#endif /* XREGISTRY */
diff --git a/dix/resource.c b/dix/resource.c
index c8297fb67..6c1b04dc7 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -151,10 +151,11 @@ Equipment Corporation.
#ifdef XSERVER_DTRACE
#include <sys/types.h>
+#include "registry.h"
typedef const char *string;
#include "Xserver-dtrace.h"
-#define TypeNameString(t) NameForAtom(ResourceNames[t & TypeMask])
+#define TypeNameString(t) LookupResourceName(t)
#endif
static void RebuildTable(
@@ -191,17 +192,17 @@ _X_EXPORT RESTYPE TypeMask;
static DeleteType *DeleteFuncs = (DeleteType *)NULL;
-#ifdef XResExtension
+_X_EXPORT CallbackListPtr ResourceStateCallback;
-_X_EXPORT Atom * ResourceNames = NULL;
-
-_X_EXPORT void RegisterResourceName (RESTYPE type, char *name)
+static _X_INLINE void
+CallResourceStateCallback(ResourceState state, ResourceRec *res)
{
- ResourceNames[type & TypeMask] = MakeAtom(name, strlen(name), TRUE);
+ if (ResourceStateCallback) {
+ ResourceStateInfoRec rsi = { state, res->id, res->type, res->value };
+ CallCallbacks(&ResourceStateCallback, &rsi);
+ }
}
-#endif
-
_X_EXPORT RESTYPE
CreateNewResourceType(DeleteType deleteFunc)
{
@@ -214,17 +215,8 @@ CreateNewResourceType(DeleteType deleteFunc)
(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
+ if (!dixRegisterPrivateOffset(next, -1))
+ return 0;
lastResourceType = next;
DeleteFuncs = funcs;
@@ -278,14 +270,6 @@ InitClientResources(ClientPtr client)
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));
@@ -490,6 +474,7 @@ AddResource(XID id, RESTYPE type, pointer value)
rrec->elements++;
if (!(id & SERVER_BIT) && (id >= rrec->expectID))
rrec->expectID = id + 1;
+ CallResourceStateCallback(ResourceStateAdding, res);
return TRUE;
}
@@ -570,8 +555,9 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
#endif
*prev = res->next;
elements = --*eltptr;
- if (rtype & RC_CACHED)
- FlushClientCaches(res->id);
+
+ CallResourceStateCallback(ResourceStateFreeing, res);
+
if (rtype != skipDeleteFuncType)
(*DeleteFuncs[rtype & TypeMask])(res->value, res->id);
xfree(res);
@@ -582,11 +568,6 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
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",
@@ -614,8 +595,9 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
res->value, TypeNameString(res->type));
#endif
*prev = res->next;
- if (type & RC_CACHED)
- FlushClientCaches(res->id);
+
+ CallResourceStateCallback(ResourceStateFreeing, res);
+
if (!skipFree)
(*DeleteFuncs[type & TypeMask])(res->value, res->id);
xfree(res);
@@ -624,11 +606,6 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
else
prev = &res->next;
}
- if(clients[cid] && (id == clients[cid]->lastDrawableID))
- {
- clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0];
- clients[cid]->lastDrawableID = WindowTable[0]->drawable.id;
- }
}
}
@@ -651,8 +628,6 @@ ChangeResourceValue (XID id, RESTYPE rtype, pointer value)
for (; res; res = res->next)
if ((res->id == id) && (res->type == rtype))
{
- if (rtype & RC_CACHED)
- FlushClientCaches(res->id);
res->value = value;
return TRUE;
}
@@ -780,10 +755,11 @@ FreeClientNeverRetainResources(ClientPtr client)
this->value, TypeNameString(this->type));
#endif
*prev = this->next;
- if (rtype & RC_CACHED)
- FlushClientCaches(this->id);
+
+ CallResourceStateCallback(ResourceStateFreeing, this);
+
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
- xfree(this);
+ xfree(this);
}
else
prev = &this->next;
@@ -830,10 +806,11 @@ FreeClientResources(ClientPtr client)
this->value, TypeNameString(this->type));
#endif
*head = this->next;
- if (rtype & RC_CACHED)
- FlushClientCaches(this->id);
+
+ CallResourceStateCallback(ResourceStateFreeing, this);
+
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
- xfree(this);
+ xfree(this);
}
}
xfree(clientTable[client->index].resources);
@@ -873,81 +850,35 @@ LegalNewID(XID id, ClientPtr client)
!LookupIDByClass(id, RC_ANY)));
}
-/* 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.
- */
-
-_X_EXPORT pointer
-SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype, Mask mode)
+_X_EXPORT int
+dixLookupResource(pointer *result, XID id, RESTYPE rtype,
+ ClientPtr client, Mask mode)
{
- int cid;
- ResourcePtr res;
- pointer retval = NULL;
-
- 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 &&
- !XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, mode, retval))
- retval = NULL;
-
- return retval;
-}
-
-
-_X_EXPORT pointer
-SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes, Mask mode)
-{
- int cid;
+ int cid = CLIENT_ID(id);
+ int istype = (rtype & TypeMask) && (rtype != RC_ANY);
ResourcePtr res = NULL;
- pointer retval = NULL;
- if (((cid = CLIENT_ID(id)) < MAXCLIENTS) &&
- clientTable[cid].buckets)
- {
+ *result = NULL;
+
+ if ((cid < 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;
+ if ((res->id == id) && ((istype && res->type == rtype) ||
+ (!istype && res->type & rtype)))
break;
- }
}
- if (retval && client &&
- !XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type, mode, retval))
- retval = NULL;
-
- return retval;
-}
-
-/* We can't replace the LookupIDByType and LookupIDByClass functions with
- * macros because of compatibility with loadable servers.
- */
-
-_X_EXPORT pointer
-LookupIDByType(XID id, RESTYPE rtype)
-{
- return SecurityLookupIDByType(NullClient, id, rtype,
- DixUnknownAccess);
-}
+ if (!res)
+ return BadValue;
+
+ if (client) {
+ client->errorValue = id;
+ cid = XaceHook(XACE_RESOURCE_ACCESS, client, id, res->type,
+ res->value, RT_NONE, NULL, mode);
+ if (cid != Success)
+ return cid;
+ }
-_X_EXPORT pointer
-LookupIDByClass(XID id, RESTYPE classes)
-{
- return SecurityLookupIDByClass(NullClient, id, classes,
- DixUnknownAccess);
+ *result = res->value;
+ return Success;
}
diff --git a/dix/window.c b/dix/window.c
index 129ebc679..0404655d4 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -126,6 +126,7 @@ Equipment Corporation.
#ifdef XAPPGROUP
#include "appgroup.h"
#endif
+#include "privates.h"
#include "xace.h"
/******
@@ -337,41 +338,6 @@ MakeRootTile(WindowPtr pWin)
}
-WindowPtr
-AllocateWindow(ScreenPtr pScreen)
-{
- WindowPtr pWin;
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- 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;
- }
-#if _XSERVER64
- pWin->drawable.pad0 = 0;
- pWin->drawable.pad1 = 0;
-#endif
- }
- return pWin;
-}
-
/*****
* CreateRootWindow
* Makes a window at initialization time for specified screen
@@ -384,7 +350,7 @@ CreateRootWindow(ScreenPtr pScreen)
BoxRec box;
PixmapFormatRec *format;
- pWin = AllocateWindow(pScreen);
+ pWin = (WindowPtr)xalloc(sizeof(WindowRec));
if (!pWin)
return FALSE;
@@ -397,6 +363,7 @@ CreateRootWindow(ScreenPtr pScreen)
pWin->drawable.pScreen = pScreen;
pWin->drawable.type = DRAWABLE_WINDOW;
+ pWin->devPrivates = NULL;
pWin->drawable.depth = pScreen->rootDepth;
for (format = screenInfo.formats;
@@ -460,6 +427,12 @@ CreateRootWindow(ScreenPtr pScreen)
pWin->border.pixel = pScreen->blackPixel;
pWin->borderWidth = 0;
+ /* security creation/labeling check
+ */
+ if (XaceHook(XACE_RESOURCE_ACCESS, serverClient, pWin->drawable.id,
+ RT_WINDOW, pWin, RT_NONE, NULL, DixCreateAccess))
+ return FALSE;
+
if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin))
return FALSE;
@@ -517,8 +490,6 @@ InitRootWindow(WindowPtr pWin)
/* We SHOULD check for an error value here XXX */
(*pScreen->ChangeWindowAttributes)(pWin, backFlag);
- XaceHook(XACE_WINDOW_INIT, serverClient, pWin);
-
MapWindow(pWin, serverClient);
}
@@ -683,13 +654,14 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
return NullWindow;
}
- pWin = AllocateWindow(pScreen);
+ pWin = (WindowPtr)xalloc(sizeof(WindowRec));
if (!pWin)
{
*error = BadAlloc;
return NullWindow;
}
pWin->drawable = pParent->drawable;
+ pWin->devPrivates = NULL;
pWin->drawable.depth = depth;
if (depth == pParent->drawable.depth)
pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel;
@@ -723,16 +695,18 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
pWin->borderWidth = bw;
- /* can't let untrusted clients have background None windows;
- * they make it too easy to steal window contents
+ /* security creation/labeling check
*/
- if (XaceHook(XACE_BACKGRND_ACCESS, client, pWin))
- pWin->backgroundState = None;
- else {
- pWin->backgroundState = BackgroundPixel;
- pWin->background.pixel = 0;
+ *error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, RT_WINDOW, pWin,
+ RT_WINDOW, pWin->parent, DixCreateAccess|DixSetAttrAccess);
+ if (*error != Success) {
+ xfree(pWin);
+ return NullWindow;
}
+ pWin->backgroundState = BackgroundPixel;
+ pWin->background.pixel = 0;
+
pWin->borderIsPixel = pParent->borderIsPixel;
pWin->border = pParent->border;
if (pWin->borderIsPixel == FALSE)
@@ -751,8 +725,6 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
REGION_NULL(pScreen, &pWin->winSize);
REGION_NULL(pScreen, &pWin->borderSize);
- XaceHook(XACE_WINDOW_INIT, client, pWin);
-
pHead = RealChildHead(pParent);
if (pHead)
{
@@ -962,11 +934,12 @@ DeleteWindow(pointer value, XID wid)
if (pWin->prevSib)
pWin->prevSib->nextSib = pWin->nextSib;
}
+ dixFreePrivates(pWin->devPrivates);
xfree(pWin);
return Success;
}
-void
+int
DestroySubwindows(WindowPtr pWin, ClientPtr client)
{
/* XXX
@@ -978,8 +951,15 @@ DestroySubwindows(WindowPtr pWin, ClientPtr client)
* If you care, simply delete the call to UnmapSubwindows.
*/
UnmapSubwindows(pWin);
- while (pWin->lastChild)
+ while (pWin->lastChild) {
+ int rc = XaceHook(XACE_RESOURCE_ACCESS, client,
+ pWin->lastChild->drawable.id, RT_WINDOW,
+ pWin->lastChild, RT_NONE, NULL, DixDestroyAccess);
+ if (rc != Success)
+ return rc;
FreeResource(pWin->lastChild->drawable.id, RT_NONE);
+ }
+ return Success;
}
#define DeviceEventMasks (KeyPressMask | KeyReleaseMask | ButtonPressMask | \
@@ -996,25 +976,20 @@ DestroySubwindows(WindowPtr pWin, ClientPtr client)
_X_EXPORT int
ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
{
- Mask index2;
XID *pVlist;
PixmapPtr pPixmap;
Pixmap pixID;
CursorPtr pCursor, pOldCursor;
Cursor cursorID;
- WindowPtr pChild;
+ WindowPtr pChild, pLayerWin;
Colormap cmap;
ColormapPtr pCmap;
xEvent xE;
- int result;
+ int error, rc;
ScreenPtr pScreen;
- Mask vmaskCopy = 0;
- Mask tmask;
+ Mask index2, tmask, vmaskCopy = 0;
unsigned int val;
- int error;
- Bool checkOptional = FALSE;
- Bool borderRelative = FALSE;
- WindowPtr pLayerWin;
+ Bool checkOptional = FALSE, borderRelative = FALSE;
if ((pWin->drawable.class == InputOnly) && (vmask & (~INPUTONLY_LEGAL_MASK)))
return BadMatch;
@@ -1036,17 +1011,13 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
borderRelative = TRUE;
if (pixID == None)
{
- /* can't let untrusted clients have background None windows */
- if (XaceHook(XACE_BACKGRND_ACCESS, client, pWin)) {
- if (pWin->backgroundState == BackgroundPixmap)
- (*pScreen->DestroyPixmap)(pWin->background.pixmap);
- if (!pWin->parent)
- MakeRootTile(pWin);
- else
- pWin->backgroundState = None;
- } else {
- /* didn't change the backgrnd to None, so don't tell ddx */
- index2 = 0;
+ if (pWin->backgroundState == BackgroundPixmap)
+ (*pScreen->DestroyPixmap)(pWin->background.pixmap);
+ if (!pWin->parent)
+ MakeRootTile(pWin);
+ else {
+ pWin->backgroundState = BackgroundPixel;
+ pWin->background.pixel = 0;
}
}
else if (pixID == ParentRelative)
@@ -1069,9 +1040,9 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
else
{
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID,
- RT_PIXMAP, DixReadAccess);
- if (pPixmap != (PixmapPtr) NULL)
+ rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
+ client, DixReadAccess);
+ if (rc == Success)
{
if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
(pPixmap->drawable.pScreen != pScreen))
@@ -1087,7 +1058,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
else
{
- error = BadPixmap;
+ error = (rc == BadValue) ? BadPixmap : rc;
client->errorValue = pixID;
goto PatchUp;
}
@@ -1116,42 +1087,40 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
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)
- {
+ if (pWin->parent->borderIsPixel == TRUE) {
+ if (pWin->borderIsPixel == FALSE)
+ (*pScreen->DestroyPixmap)(pWin->border.pixmap);
+ pWin->border = pWin->parent->border;
+ pWin->borderIsPixel = TRUE;
index2 = CWBorderPixel;
+ break;
}
else
{
- pWin->parent->border.pixmap->refcnt++;
+ pixID = pWin->parent->border.pixmap->drawable.id;
}
}
- else
- {
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client, pixID,
- RT_PIXMAP, DixReadAccess);
- 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
+ rc = dixLookupResource((pointer *)&pPixmap, pixID, RT_PIXMAP,
+ client, DixReadAccess);
+ if (rc == Success)
+ {
+ if ((pPixmap->drawable.depth != pWin->drawable.depth) ||
+ (pPixmap->drawable.pScreen != pScreen))
{
- error = BadPixmap;
- client->errorValue = pixID;
+ error = BadMatch;
goto PatchUp;
}
+ if (pWin->borderIsPixel == FALSE)
+ (*pScreen->DestroyPixmap)(pWin->border.pixmap);
+ pWin->borderIsPixel = FALSE;
+ pWin->border.pixmap = pPixmap;
+ pPixmap->refcnt++;
+ }
+ else
+ {
+ error = (rc == BadValue) ? BadPixmap : rc;
+ client->errorValue = pixID;
+ goto PatchUp;
}
break;
case CWBorderPixel:
@@ -1276,20 +1245,20 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
#endif /* DO_SAVE_UNDERS */
break;
case CWEventMask:
- result = EventSelectForWindow(pWin, client, (Mask )*pVlist);
- if (result)
+ rc = EventSelectForWindow(pWin, client, (Mask )*pVlist);
+ if (rc)
{
- error = result;
+ error = rc;
goto PatchUp;
}
pVlist++;
break;
case CWDontPropagate:
- result = EventSuppressForWindow(pWin, client, (Mask )*pVlist,
+ rc = EventSuppressForWindow(pWin, client, (Mask )*pVlist,
&checkOptional);
- if (result)
+ if (rc)
{
- error = result;
+ error = rc;
goto PatchUp;
}
pVlist++;
@@ -1303,6 +1272,15 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
client->errorValue = val;
goto PatchUp;
}
+ if (val == xTrue) {
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id,
+ RT_WINDOW, pWin, RT_NONE, NULL, DixGrabAccess);
+ if (rc != Success) {
+ error = rc;
+ client->errorValue = pWin->drawable.id;
+ goto PatchUp;
+ }
+ }
pWin->overrideRedirect = val;
break;
case CWColormap:
@@ -1340,11 +1318,11 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
error = BadMatch;
goto PatchUp;
}
- pCmap = (ColormapPtr)SecurityLookupIDByType(client, cmap,
- RT_COLORMAP, DixReadAccess);
- if (!pCmap)
+ rc = dixLookupResource((pointer *)&pCmap, cmap, RT_COLORMAP,
+ client, DixUseAccess);
+ if (rc != Success)
{
- error = BadColor;
+ error = (rc == BadValue) ? BadColor : rc;
client->errorValue = cmap;
goto PatchUp;
}
@@ -1416,11 +1394,11 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
}
else
{
- pCursor = (CursorPtr)SecurityLookupIDByType(client, cursorID,
- RT_CURSOR, DixReadAccess);
- if (!pCursor)
+ rc = dixLookupResource((pointer *)&pCursor, cursorID,
+ RT_CURSOR, client, DixUseAccess);
+ if (rc != Success)
{
- error = BadCursor;
+ error = (rc == BadValue) ? BadCursor : rc;
client->errorValue = cursorID;
goto PatchUp;
}
@@ -2253,7 +2231,7 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
unsigned short w = pWin->drawable.width,
h = pWin->drawable.height,
bw = pWin->borderWidth;
- int action, smode = Above;
+ int rc, action, smode = Above;
#ifdef XAPPGROUP
ClientPtr win_owner;
ClientPtr ag_leader = NULL;
@@ -2314,12 +2292,11 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
case CWSibling:
sibwid = (Window ) *pVlist;
pVlist++;
- pSib = (WindowPtr )SecurityLookupIDByType(client, sibwid,
- RT_WINDOW, DixReadAccess);
- if (!pSib)
+ rc = dixLookupWindow(&pSib, sibwid, client, DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = sibwid;
- return(BadWindow);
+ return rc;
}
if (pSib->parent != pParent)
return(BadMatch);
@@ -2766,8 +2743,9 @@ MapWindow(WindowPtr pWin, ClientPtr client)
return(Success);
/* general check for permission to map window */
- if (!XaceHook(XACE_MAP_ACCESS, client, pWin))
- return Success;
+ if (XaceHook(XACE_RESOURCE_ACCESS, client, pWin->drawable.id, RT_WINDOW,
+ pWin, RT_NONE, NULL, DixShowAccess) != Success)
+ return Success;
pScreen = pWin->drawable.pScreen;
if ( (pParent = pWin->parent) )
@@ -3351,12 +3329,10 @@ static void DrawLogo(
);
#endif
-_X_EXPORT void
-SaveScreens(int on, int mode)
+_X_EXPORT int
+dixSaveScreens(ClientPtr client, int on, int mode)
{
- int i;
- int what;
- int type;
+ int rc, i, what, type;
if (on == SCREEN_SAVER_FORCER)
{
@@ -3375,6 +3351,13 @@ SaveScreens(int on, int mode)
if (what == screenIsSaved)
type = SCREEN_SAVER_CYCLE;
}
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i],
+ DixShowAccess | DixHideAccess);
+ if (rc != Success)
+ return rc;
+ }
for (i = 0; i < screenInfo.numScreens; i++)
{
if (on == SCREEN_SAVER_FORCER)
@@ -3462,6 +3445,13 @@ SaveScreens(int on, int mode)
screenIsSaved = what;
if (mode == ScreenSaverReset)
SetScreenSaverTimer();
+ return Success;
+}
+
+_X_EXPORT int
+SaveScreens(int on, int mode)
+{
+ return dixSaveScreens(serverClient, on, mode);
}
static Bool
@@ -3523,7 +3513,8 @@ TileScreenSaver(int i, int kind)
{
for (j=0; j<BitmapBytePad(32)*16; j++)
srcbits[j] = mskbits[j] = 0x0;
- cursor = AllocCursor(srcbits, mskbits, &cm, 0, 0, 0, 0, 0, 0);
+ result = AllocARGBCursor(srcbits, mskbits, NULL, &cm, 0, 0, 0, 0, 0, 0,
+ &cursor, serverClient, (XID)0);
if (cursor)
{
cursorID = FakeClientID(0);
diff --git a/doc/Makefile.am b/doc/Makefile.am
index ce1979d4f..d3911c9bf 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -5,7 +5,7 @@ filemandir = $(FILE_MAN_DIR)
# (i.e. those handled in the os/utils.c options processing instead of in
# the DDX-level options processing)
appman_PRE = Xserver.man.pre
-fileman_PRE = SecurityPolicy.man.pre
+fileman_PRE =
appman_PROCESSED = $(appman_PRE:man.pre=man)
fileman_PROCESSED = $(fileman_PRE:man.pre=man)
diff --git a/doc/SecurityPolicy.man.pre b/doc/SecurityPolicy.man.pre
deleted file mode 100644
index f5aff0c6c..000000000
--- a/doc/SecurityPolicy.man.pre
+++ /dev/null
@@ -1,258 +0,0 @@
-.\" Split out of Xserver.man, which was covered by this notice:
-.\" 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 SecurityPolicy __filemansuffix__ __xorgversion__
-.SH NAME
-SecurityPolicy \- X Window System SECURITY Extension Policy file format
-.SH DESCRIPTION
-The SECURITY extension to the X Window System uses a policy file to determine
-which operations should be allowed or denied. The default location for this
-file is
-.IR __projectroot__/lib/xserver/SecurityPolicy .
-.PP
-The syntax of the security policy file is as follows.
-Notation: "*" means zero or more occurrences of the preceding element,
-and "+" means one or more occurrences. To interpret <foo/bar>, ignore
-the text after the /; it is used to distinguish between instances of
-<foo> in the next section.
-.PP
-.nf
-<policy file> ::= <version line> <other line>*
-
-<version line> ::= <string/v> '\en'
-
-<other line > ::= <comment> | <access rule> | <site policy> | <blank line>
-
-<comment> ::= # <not newline>* '\en'
-
-<blank line> ::= <space> '\en'
-
-<site policy> ::= sitepolicy <string/sp> '\en'
-
-<access rule> ::= property <property/ar> <window> <perms> '\en'
-
-<property> ::= <string>
-
-<window> ::= any | root | <required property>
-
-<required property> ::= <property/rp> | <property with value>
-
-<property with value> ::= <property/rpv> = <string/rv>
-
-<perms> ::= [ <operation> | <action> | <space> ]*
-
-<operation> ::= r | w | d
-
-<action> ::= a | i | e
-
-<string> ::= <dbl quoted string> | <single quoted string> | <unquoted string>
-
-<dbl quoted string> ::= <space> " <not dquote>* " <space>
-
-<single quoted string> ::= <space> ' <not squote>* ' <space>
-
-<unquoted string> ::= <space> <not space>+ <space>
-
-<space> ::= [ ' ' | '\et' ]*
-
-Character sets:
-
-<not newline> ::= any character except '\en'
-<not dquote> ::= any character except "
-<not squote> ::= any character except '
-<not space> ::= any character except those in <space>
-.fi
-.PP
-The semantics associated with the above syntax are as follows.
-.PP
-<version line>, the first line in the file, specifies the file format
-version. If the server does not recognize the version <string/v>, it
-ignores the rest of the file. The version string for the file format
-described here is "version-1" .
-.PP
-Once past the <version line>, lines that do not match the above syntax
-are ignored.
-.PP
-<comment> lines are ignored.
-.PP
-<sitepolicy> lines are currently ignored. They are intended to
-specify the site policies used by the XC-QUERY-SECURITY-1
-authorization method.
-.PP
-<access rule> lines specify how the server should react to untrusted
-client requests that affect the X Window property named <property/ar>.
-The rest of this section describes the interpretation of an
-<access rule>.
-.PP
-For an <access rule> to apply to a given instance of <property/ar>,
-<property/ar> must be on a window that is in the set of windows
-specified by <window>. If <window> is any, the rule applies to
-<property/ar> on any window. If <window> is root, the rule applies to
-<property/ar> only on root windows.
-.PP
-If <window> is <required property>, the following apply. If <required
-property> is a <property/rp>, the rule applies when the window also
-has that <property/rp>, regardless of its value. If <required
-property> is a <property with value>, <property/rpv> must also have
-the value specified by <string/rv>. In this case, the property must
-have type STRING and format 8, and should contain one or more
-null-terminated strings. If any of the strings match <string/rv>, the
-rule applies.
-.PP
-The definition of string matching is simple case-sensitive string
-comparison with one elaboration: the occurrence of the character '*' in
-<string/rv> is a wildcard meaning "any string." A <string/rv> can
-contain multiple wildcards anywhere in the string. For example, "x*"
-matches strings that begin with x, "*x" matches strings that end with
-x, "*x*" matches strings containing x, and "x*y*" matches strings that
-start with x and subsequently contain y.
-.PP
-There may be multiple <access rule> lines for a given <property/ar>.
-The rules are tested in the order that they appear in the file. The
-first rule that applies is used.
-.PP
-<perms> specify operations that untrusted clients may attempt, and
-the actions that the server should take in response to those operations.
-.PP
-<operation> can be r (read), w (write), or d (delete). The following
-table shows how X Protocol property requests map to these operations
-in the X.Org server implementation.
-.PP
-.nf
-GetProperty r, or r and d if delete = True
-ChangeProperty w
-RotateProperties r and w
-DeleteProperty d
-ListProperties none, untrusted clients can always list all properties
-.fi
-.PP
-<action> can be a (allow), i (ignore), or e (error). Allow means
-execute the request as if it had been issued by a trusted client.
-Ignore means treat the request as a no-op. In the case of
-GetProperty, ignore means return an empty property value if the
-property exists, regardless of its actual value. Error means do not
-execute the request and return a BadAtom error with the atom set to
-the property name. Error is the default action for all properties,
-including those not listed in the security policy file.
-.PP
-An <action> applies to all <operation>s that follow it, until the next
-<action> is encountered. Thus, irwad means ignore read and write,
-allow delete.
-.PP
-GetProperty and RotateProperties may do multiple operations (r and d,
-or r and w). If different actions apply to the operations, the most
-severe action is applied to the whole request; there is no partial
-request execution. The severity ordering is: allow < ignore < error.
-Thus, if the <perms> for a property are ired (ignore read, error
-delete), and an untrusted client attempts GetProperty on that property
-with delete = True, an error is returned, but the property value is
-not. Similarly, if any of the properties in a RotateProperties do not
-allow both read and write, an error is returned without changing any
-property values.
-.PP
-Here is an example security policy file.
-.PP
-.ta 3i 4i
-.nf
-version-1
-
-XCOMM Allow reading of application resources, but not writing.
-property RESOURCE_MANAGER root ar iw
-property SCREEN_RESOURCES root ar iw
-
-XCOMM Ignore attempts to use cut buffers. Giving errors causes apps to crash,
-XCOMM and allowing access may give away too much information.
-property CUT_BUFFER0 root irw
-property CUT_BUFFER1 root irw
-property CUT_BUFFER2 root irw
-property CUT_BUFFER3 root irw
-property CUT_BUFFER4 root irw
-property CUT_BUFFER5 root irw
-property CUT_BUFFER6 root irw
-property CUT_BUFFER7 root irw
-
-XCOMM If you are using Motif, you probably want these.
-property _MOTIF_DEFAULT_BINDINGS root ar iw
-property _MOTIF_DRAG_WINDOW root ar iw
-property _MOTIF_DRAG_TARGETS any ar iw
-property _MOTIF_DRAG_ATOMS any ar iw
-property _MOTIF_DRAG_ATOM_PAIRS any ar iw
-
-XCOMM The next two rules let xwininfo -tree work when untrusted.
-property WM_NAME any ar
-
-XCOMM Allow read of WM_CLASS, but only for windows with WM_NAME.
-XCOMM This might be more restrictive than necessary, but demonstrates
-XCOMM the <required property> facility, and is also an attempt to
-XCOMM say "top level windows only."
-property WM_CLASS WM_NAME ar
-
-XCOMM These next three let xlsclients work untrusted. Think carefully
-XCOMM before including these; giving away the client machine name and command
-XCOMM may be exposing too much.
-property WM_STATE WM_NAME ar
-property WM_CLIENT_MACHINE WM_NAME ar
-property WM_COMMAND WM_NAME ar
-
-XCOMM To let untrusted clients use the standard colormaps created by
-XCOMM xstdcmap, include these lines.
-property RGB_DEFAULT_MAP root ar
-property RGB_BEST_MAP root ar
-property RGB_RED_MAP root ar
-property RGB_GREEN_MAP root ar
-property RGB_BLUE_MAP root ar
-property RGB_GRAY_MAP root ar
-
-XCOMM To let untrusted clients use the color management database created
-XCOMM by xcmsdb, include these lines.
-property XDCCC_LINEAR_RGB_CORRECTION root ar
-property XDCCC_LINEAR_RGB_MATRICES root ar
-property XDCCC_GRAY_SCREENWHITEPOINT root ar
-property XDCCC_GRAY_CORRECTION root ar
-
-XCOMM To let untrusted clients use the overlay visuals that many vendors
-XCOMM support, include this line.
-property SERVER_OVERLAY_VISUALS root ar
-
-XCOMM Dumb examples to show other capabilities.
-
-XCOMM oddball property names and explicit specification of error conditions
-property "property with spaces" 'property with "' aw er ed
-
-XCOMM Allow deletion of Woo-Hoo if window also has property OhBoy with value
-XCOMM ending in "son". Reads and writes will cause an error.
-property Woo-Hoo OhBoy = "*son" ad
-
-.fi
-.SH FILES
-.TP 30
-.I __projectroot__/lib/xserver/SecurityPolicy
-Default X server security policy
-.SH "SEE ALSO"
-.PP
-\fIXserver\fp(__appmansuffix__),
-.I "Security Extension Specification"
diff --git a/doc/Xserver.man.pre b/doc/Xserver.man.pre
index c9ee019c6..c47a3966b 100644
--- a/doc/Xserver.man.pre
+++ b/doc/Xserver.man.pre
@@ -407,15 +407,6 @@ elapse between autorepeat-generated keystrokes).
.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.
-The syntax of the security policy file is described in
-\fISecurityPolicy\fP(__filemansuffix__).
.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,
@@ -580,9 +571,6 @@ Error log file for display number \fBn\fP if run from \fIinit\fP(__adminmansuffi
.TP 30
.I __projectroot__/lib/X11/xdm/xdm-errors
Default error log file if the server is run from \fIxdm\fP(1)
-.TP 30
-.I __projectroot__/lib/xserver/SecurityPolicy
-Default X server security policy
.SH "SEE ALSO"
General information: \fIX\fP(__miscmansuffix__)
.PP
@@ -597,7 +585,6 @@ Fonts: \fIbdftopcf\fP(1), \fImkfontdir\fP(1), \fImkfontscale\fP(1),
.PP
Security: \fIXsecurity\fP(__miscmansuffix__), \fIxauth\fP(1), \fIXau\fP(1),
\fIxdm\fP(1), \fIxhost\fP(1), \fIxfwp\fP(1),
-\fISecurityPolicy\fP(__filemansuffix__),
.I "Security Extension Specification"
.PP
Starting the server: \fIxdm\fP(1), \fIxinit\fP(1)
diff --git a/exa/exa.c b/exa/exa.c
index 4ed1a1ad3..cbe66e875 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -40,9 +40,8 @@
#include "exa.h"
#include "cw.h"
-static int exaGeneration;
-int exaScreenPrivateIndex;
-int exaPixmapPrivateIndex;
+DevPrivateKey exaScreenPrivateKey = &exaScreenPrivateKey;
+DevPrivateKey exaPixmapPrivateKey = &exaPixmapPrivateKey;
static _X_INLINE void*
ExaGetPixmapAddress(PixmapPtr p)
@@ -813,12 +812,6 @@ exaDriverInit (ScreenPtr pScreen,
#ifdef RENDER
ps = GetPictureScreenIfSet(pScreen);
#endif
- if (exaGeneration != serverGeneration)
- {
- exaScreenPrivateIndex = AllocateScreenPrivateIndex();
- exaPixmapPrivateIndex = AllocatePixmapPrivateIndex();
- exaGeneration = serverGeneration;
- }
pExaScr = xcalloc (sizeof (ExaScreenPrivRec), 1);
@@ -830,7 +823,7 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr->info = pScreenInfo;
- pScreen->devPrivates[exaScreenPrivateIndex].ptr = (pointer) pExaScr;
+ dixSetPrivate(&pScreen->devPrivates, exaScreenPrivateKey, pExaScr);
pExaScr->migration = ExaMigrationAlways;
@@ -885,8 +878,7 @@ exaDriverInit (ScreenPtr pScreen,
*/
if (pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS)
{
- if (!AllocatePixmapPrivate(pScreen, exaPixmapPrivateIndex,
- sizeof (ExaPixmapPrivRec))) {
+ if (!dixRequestPrivate(exaPixmapPrivateKey, sizeof(ExaPixmapPrivRec))) {
LogMessage(X_WARNING,
"EXA(%d): Failed to allocate pixmap private\n",
pScreen->myNum);
@@ -911,11 +903,7 @@ exaDriverInit (ScreenPtr pScreen,
}
}
else
- {
LogMessage(X_INFO, "EXA(%d): No offscreen pixmaps\n", pScreen->myNum);
- if (!AllocatePixmapPrivate(pScreen, exaPixmapPrivateIndex, 0))
- return FALSE;
- }
if (!pExaScr->info->CreatePixmap) {
DBG_PIXMAP(("============== %ld < %ld\n", pExaScr->info->offScreenBase,
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 7656a0278..de8b2f541 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -134,9 +134,9 @@ typedef struct {
(PixmapWidthPaddingInfo[d].padRoundUp+1)))
#endif
-extern int exaScreenPrivateIndex;
-extern int exaPixmapPrivateIndex;
-#define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)(s)->devPrivates[exaScreenPrivateIndex].ptr)
+extern DevPrivateKey exaScreenPrivateKey;
+extern DevPrivateKey exaPixmapPrivateKey;
+#define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)dixLookupPrivate(&(s)->devPrivates, exaScreenPrivateKey))
#define ExaScreenPriv(s) ExaScreenPrivPtr pExaScr = ExaGetScreenPriv(s)
/** Align an offset to an arbitrary alignment */
@@ -152,8 +152,8 @@ extern int exaPixmapPrivateIndex;
#define EXA_PIXMAP_SCORE_PINNED 1000
#define EXA_PIXMAP_SCORE_INIT 1001
-#define ExaGetPixmapPriv(p) ((ExaPixmapPrivPtr)(p)->devPrivates[exaPixmapPrivateIndex].ptr)
-#define ExaSetPixmapPriv(p,a) ((p)->devPrivates[exaPixmapPrivateIndex].ptr = (pointer) (a))
+#define ExaGetPixmapPriv(p) ((ExaPixmapPrivPtr)dixLookupPrivate(&(p)->devPrivates, exaPixmapPrivateKey))
+#define ExaSetPixmapPriv(p,a) dixSetPrivate(&(p)->devPrivates, exaPixmapPrivateKey, a)
#define ExaPixmapPriv(p) ExaPixmapPrivPtr pExaPixmap = ExaGetPixmapPriv(p)
#define EXA_RANGE_PITCH (1 << 0)
diff --git a/fb/fb.h b/fb/fb.h
index 5c01c56c8..5b56d96a2 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -37,6 +37,7 @@
#include "miscstruct.h"
#include "servermd.h"
#include "windowstr.h"
+#include "privates.h"
#include "mi.h"
#include "migc.h"
#include "mibstore.h"
@@ -598,13 +599,9 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data);
} \
}
-/* XXX fb*PrivateIndex should be static, but it breaks the ABI */
-
-extern int fbGCPrivateIndex;
-extern int fbGetGCPrivateIndex(void);
+extern DevPrivateKey fbGetGCPrivateKey(void);
#ifndef FB_NO_WINDOW_PIXMAPS
-extern int fbWinPrivateIndex;
-extern int fbGetWinPrivateIndex(void);
+extern DevPrivateKey fbGetWinPrivateKey(void);
#endif
extern const GCOps fbGCOps;
extern const GCFuncs fbGCFuncs;
@@ -640,8 +637,7 @@ typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw);
#ifdef FB_SCREEN_PRIVATE
-extern int fbScreenPrivateIndex;
-extern int fbGetScreenPrivateIndex(void);
+extern DevPrivateKey fbGetScreenPrivateKey(void);
/* private field of a screen */
typedef struct {
@@ -654,7 +650,7 @@ typedef struct {
} FbScreenPrivRec, *FbScreenPrivPtr;
#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
- (pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr)
+ dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
#endif
/* private field of GC */
@@ -669,7 +665,7 @@ typedef struct {
} FbGCPrivRec, *FbGCPrivPtr;
#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
- (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey()))
#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
#define fbGetExpose(pGC) ((pGC)->fExpose)
@@ -681,7 +677,7 @@ typedef struct {
#define fbGetWindowPixmap(d) fbGetScreenPixmap(((DrawablePtr) (d))->pScreen)
#else
#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
- ((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr)
+ dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
#endif
#ifdef ROOTLESS
@@ -834,7 +830,7 @@ fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
* fballpriv.c
*/
Bool
-fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex);
+fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex);
/*
* fbarc.c
diff --git a/fb/fballpriv.c b/fb/fballpriv.c
index 8efb8fa99..68cb2e4c0 100644
--- a/fb/fballpriv.c
+++ b/fb/fballpriv.c
@@ -27,51 +27,33 @@
#include "fb.h"
#ifdef FB_SCREEN_PRIVATE
-int fbScreenPrivateIndex;
-int fbGetScreenPrivateIndex(void)
+static DevPrivateKey fbScreenPrivateKey = &fbScreenPrivateKey;
+DevPrivateKey fbGetScreenPrivateKey(void)
{
- return fbScreenPrivateIndex;
+ return fbScreenPrivateKey;
}
#endif
-int fbGCPrivateIndex;
-int fbGetGCPrivateIndex(void)
+static DevPrivateKey fbGCPrivateKey = &fbGCPrivateKey;
+DevPrivateKey fbGetGCPrivateKey(void)
{
- return fbGCPrivateIndex;
+ return fbGCPrivateKey;
}
#ifndef FB_NO_WINDOW_PIXMAPS
-int fbWinPrivateIndex;
-int fbGetWinPrivateIndex(void)
+static DevPrivateKey fbWinPrivateKey = &fbWinPrivateKey;
+DevPrivateKey fbGetWinPrivateKey(void)
{
- return fbWinPrivateIndex;
+ return fbWinPrivateKey;
}
#endif
-int fbGeneration;
Bool
-fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
+fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
{
- 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)))
+ if (pGCKey)
+ *pGCKey = fbGCPrivateKey;
+
+ if (!dixRequestPrivate(fbGCPrivateKey, sizeof(FbGCPrivRec)))
return FALSE;
-#ifndef FB_NO_WINDOW_PIXMAPS
- if (!AllocateWindowPrivate(pScreen, fbWinPrivateIndex, 0))
- return FALSE;
-#endif
#ifdef FB_SCREEN_PRIVATE
{
FbScreenPrivPtr pScreenPriv;
@@ -79,7 +61,7 @@ fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
pScreenPriv = (FbScreenPrivPtr) xalloc (sizeof (FbScreenPrivRec));
if (!pScreenPriv)
return FALSE;
- pScreen->devPrivates[fbScreenPrivateIndex].ptr = (pointer) pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, fbScreenPrivateKey, pScreenPriv);
}
#endif
return TRUE;
diff --git a/fb/fboverlay.c b/fb/fboverlay.c
index 456c921a6..f9f7c52a3 100644
--- a/fb/fboverlay.c
+++ b/fb/fboverlay.c
@@ -33,12 +33,11 @@
#include "fboverlay.h"
#include "shmint.h"
-int fbOverlayGeneration;
-int fbOverlayScreenPrivateIndex = -1;
+static DevPrivateKey fbOverlayScreenPrivateKey = &fbOverlayScreenPrivateKey;
-int fbOverlayGetScreenPrivateIndex(void)
+DevPrivateKey fbOverlayGetScreenPrivateKey(void)
{
- return fbOverlayScreenPrivateIndex;
+ return fbOverlayScreenPrivateKey;
}
/*
@@ -65,7 +64,7 @@ fbOverlayCreateWindow(WindowPtr pWin)
pPixmap = pScrPriv->layer[i].u.run.pixmap;
if (pWin->drawable.depth == pPixmap->drawable.depth)
{
- pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pPixmap;
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap);
/*
* Make sure layer keys are written correctly by
* having non-root layers set to full while the
@@ -108,7 +107,7 @@ fbOverlayWindowLayer(WindowPtr pWin)
int i;
for (i = 0; i < pScrPriv->nlayers; i++)
- if (pWin->devPrivates[fbWinPrivateIndex].ptr ==
+ if (dixLookupPrivate(&pWin->devPrivates, fbGetWinPrivateKey()) ==
(pointer) pScrPriv->layer[i].u.run.pixmap)
return i;
return 0;
@@ -348,12 +347,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
VisualID defaultVisual;
FbOverlayScrPrivPtr pScrPriv;
- if (fbOverlayGeneration != serverGeneration)
- {
- fbOverlayScreenPrivateIndex = AllocateScreenPrivateIndex ();
- fbOverlayGeneration = serverGeneration;
- }
-
pScrPriv = xalloc (sizeof (FbOverlayScrPrivRec));
if (!pScrPriv)
return FALSE;
@@ -423,7 +416,7 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
pScrPriv->layer[1].u.init.width = width2;
pScrPriv->layer[1].u.init.depth = depth2;
- pScreen->devPrivates[fbOverlayScreenPrivateIndex].ptr = (pointer) pScrPriv;
+ dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv);
/* overwrite miCloseScreen with our own */
pScreen->CloseScreen = fbOverlayCloseScreen;
diff --git a/fb/fboverlay.h b/fb/fboverlay.h
index 55135ea4e..f3db0bb7d 100644
--- a/fb/fboverlay.h
+++ b/fb/fboverlay.h
@@ -25,9 +25,9 @@
#ifndef _FBOVERLAY_H_
#define _FBOVERLAY_H_
-extern int fbOverlayGeneration;
-extern int fbOverlayScreenPrivateIndex; /* XXX should be static */
-extern int fbOverlayGetScreenPrivateIndex(void);
+#include "privates.h"
+
+extern DevPrivateKey fbOverlayGetScreenPrivateKey(void);
#ifndef FB_OVERLAY_MAX
#define FB_OVERLAY_MAX 2
@@ -58,8 +58,7 @@ typedef struct _fbOverlayScrPriv {
} FbOverlayScrPrivRec, *FbOverlayScrPrivPtr;
#define fbOverlayGetScrPriv(s) \
- ((fbOverlayGetScreenPrivateIndex() != -1) ? \
- (s)->devPrivates[fbOverlayGetScreenPrivateIndex()].ptr : NULL)
+ dixLookupPrivate(&(s)->devPrivates, fbOverlayGetScreenPrivateKey())
Bool
fbOverlayCreateWindow(WindowPtr pWin);
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index b9c93ea96..311da9e62 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -100,6 +100,7 @@ fbDestroyPixmap (PixmapPtr pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/fb/fbpseudocolor.c b/fb/fbpseudocolor.c
index 8a48c3819..06cf15992 100644
--- a/fb/fbpseudocolor.c
+++ b/fb/fbpseudocolor.c
@@ -123,13 +123,11 @@ typedef struct {
} xxScrPrivRec, *xxScrPrivPtr;
#define xxGetScrPriv(s) ((xxScrPrivPtr) \
- (xxScrPrivateIndex != -1) \
- ? (s)->devPrivates[xxScrPrivateIndex].ptr\
- : NULL)
+ dixLookupPrivate(&(s)->devPrivates, xxScrPrivateKey))
#define xxScrPriv(s) xxScrPrivPtr pScrPriv = xxGetScrPriv(s)
#define xxGetCmapPriv(s) ((xxCmapPrivPtr) \
- (s)->devPrivates[xxColormapPrivateIndex].ptr)
+ dixLookupPrivate(&(s)->devPrivates, xxColormapPrivateKey))
#define xxCmapPriv(s) xxCmapPrivPtr pCmapPriv = xxGetCmapPriv(s);
typedef struct _xxGCPriv {
@@ -138,13 +136,12 @@ typedef struct _xxGCPriv {
} xxGCPrivRec, *xxGCPrivPtr;
#define xxGetGCPriv(pGC) ((xxGCPrivPtr) \
- (pGC)->devPrivates[xxGCPrivateIndex].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, xxGCPrivateKey))
#define xxGCPriv(pGC) xxGCPrivPtr pGCPriv = xxGetGCPriv(pGC)
-int xxScrPrivateIndex = -1;
-int xxGCPrivateIndex;
-int xxColormapPrivateIndex = -1;
-int xxGeneration;
+static DevPrivateKey xxScrPrivateKey = &xxScrPrivateKey;
+static DevPrivateKey xxGCPrivateKey = &xxGCPrivateKey;
+static DevPrivateKey xxColormapPrivateKey = &xxColormapPrivateKey;
#define wrap(priv,real,mem,func) {\
@@ -354,26 +351,20 @@ xxMyVisual(ScreenPtr pScreen, VisualID vid)
}
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;
+ dixSetPrivate(&pmap->devPrivates, xxColormapPrivateKey, (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;
+ dixSetPrivate(&pmap->devPrivates, xxColormapPrivateKey, pCmapPriv);
cmap = xalloc(sizeof (CARD32) * (1 << pScrPriv->myDepth));
if (!cmap)
return FALSE;
@@ -675,7 +666,7 @@ xxCreateWindow(WindowPtr pWin)
DBG("CreateWindow\n");
- pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pScrPriv->pPixmap;
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pScrPriv->pPixmap);
PRINT_RECTS(pScrPriv->region);
if (!pWin->parent) {
REGION_EMPTY (pWin->drawable.pScreen, &pScrPriv->region);
@@ -744,9 +735,10 @@ xxCopyWindow(WindowPtr pWin,
xxPickMyWindows(pWin,&rgn);
unwrap (pScrPriv, pScreen, CopyWindow);
- pWin->devPrivates[fbWinPrivateIndex].ptr = fbGetScreenPixmap(pScreen);
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
+ fbGetScreenPixmap(pScreen));
pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc);
- pWin->devPrivates[fbWinPrivateIndex].ptr = pPixmap;
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap);
wrap(pScrPriv, pScreen, CopyWindow, xxCopyWindow);
REGION_INTERSECT(pScreen,&rgn,&rgn,&rgn_new);
@@ -1032,21 +1024,7 @@ xxSetup(ScreenPtr pScreen, int myDepth, int baseDepth, char* addr, xxSyncFunc sy
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)))
+ if (!dixRequestPrivate(xxGCPrivateKey, sizeof (xxGCPrivRec)))
return FALSE;
pScrPriv = (xxScrPrivPtr) xalloc (sizeof (xxScrPrivRec));
@@ -1122,7 +1100,7 @@ xxSetup(ScreenPtr pScreen, int myDepth, int baseDepth, char* addr, xxSyncFunc sy
}
#endif
pScrPriv->addr = addr;
- pScreen->devPrivates[xxScrPrivateIndex].ptr = (pointer) pScrPriv;
+ dixSetPrivate(&pScreen->devPrivates, xxScrPrivateKey, pScrPriv);
pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP);
if (!xxInitColormapPrivate(pDefMap))
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 41bef4739..12b19e419 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -38,7 +38,7 @@ fbCloseScreen (int index, ScreenPtr pScreen)
xfree (pScreen->visuals);
xfree (pScreen->devPrivate);
#ifdef FB_SCREEN_PRIVATE
- xfree (pScreen->devPrivates[fbScreenPrivateIndex].ptr);
+ xfree (dixLookupPrivate(&pScreen->devPrivates, fbGetScreenPrivateKey()));
#endif
return TRUE;
}
@@ -93,7 +93,7 @@ _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;
+ dixSetPrivate(&pWindow->devPrivates, fbGetWinPrivateKey(), pPixmap);
#endif
}
@@ -107,7 +107,7 @@ fbSetupScreen(ScreenPtr pScreen,
int width, /* pixel width of frame buffer */
int bpp) /* bits per pixel for screen */
{
- if (!fbAllocatePrivates(pScreen, (int *) 0))
+ if (!fbAllocatePrivates(pScreen, NULL))
return FALSE;
pScreen->defColormap = FakeClientID(0);
/* let CreateDefColormap do whatever it wants for pixels */
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index 602b7e0dc..89f601f29 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -32,8 +32,8 @@ Bool
fbCreateWindow(WindowPtr pWin)
{
#ifndef FB_NO_WINDOW_PIXMAPS
- pWin->devPrivates[fbWinPrivateIndex].ptr =
- (pointer) fbGetScreenPixmap(pWin->drawable.pScreen);
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
+ fbGetScreenPixmap(pWin->drawable.pScreen));
#endif
#ifdef FB_SCREEN_PRIVATE
if (pWin->drawable.bitsPerPixel == 32)
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index 93ce41baf..93822442f 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -84,14 +84,14 @@
#define fbFixCoordModePrevious wfbFixCoordModePrevious
#define fbGCFuncs wfbGCFuncs
#define fbGCOps wfbGCOps
-#define fbGCPrivateIndex wfbGCPrivateIndex
+#define fbGCPrivateKey wfbGCPrivateKey
#define fbGeneration wfbGeneration
-#define fbGetGCPrivateIndex wfbGetGCPrivateIndex
+#define fbGetGCPrivateKey wfbGetGCPrivateKey
#define fbGetImage wfbGetImage
-#define fbGetScreenPrivateIndex wfbGetScreenPrivateIndex
+#define fbGetScreenPrivateKey wfbGetScreenPrivateKey
#define fbGetSpans wfbGetSpans
#define _fbGetWindowPixmap _wfbGetWindowPixmap
-#define fbGetWinPrivateIndex wfbGetWinPrivateIndex
+#define fbGetWinPrivateKey wfbGetWinPrivateKey
#define fbGlyph16 wfbGlyph16
#define fbGlyph24 wfbGlyph24
#define fbGlyph32 wfbGlyph32
@@ -117,9 +117,9 @@
#define fbOverlayCreateWindow wfbOverlayCreateWindow
#define fbOverlayFinishScreenInit wfbOverlayFinishScreenInit
#define fbOverlayGeneration wfbOverlayGeneration
-#define fbOverlayGetScreenPrivateIndex wfbOverlayGetScreenPrivateIndex
+#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey
#define fbOverlayPaintKey wfbOverlayPaintKey
-#define fbOverlayScreenPrivateIndex wfbOverlayScreenPrivateIndex
+#define fbOverlayScreenPrivateKey wfbOverlayScreenPrivateKey
#define fbOverlaySetupScreen wfbOverlaySetupScreen
#define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion
#define fbOverlayWindowExposures wfbOverlayWindowExposures
@@ -158,7 +158,7 @@
#define fbResolveColor wfbResolveColor
#define fbRestoreAreas wfbRestoreAreas
#define fbSaveAreas wfbSaveAreas
-#define fbScreenPrivateIndex wfbScreenPrivateIndex
+#define fbScreenPrivateKey wfbScreenPrivateKey
#define fbSegment wfbSegment
#define fbSelectBres wfbSelectBres
#define fbSetSpans wfbSetSpans
@@ -183,14 +183,14 @@
#define fbUnrealizeFont wfbUnrealizeFont
#define fbValidateGC wfbValidateGC
#define fbWalkCompositeRegion wfbWalkCompositeRegion
-#define fbWinPrivateIndex wfbWinPrivateIndex
+#define fbWinPrivateKey wfbWinPrivateKey
#define fbZeroLine wfbZeroLine
#define fbZeroSegment wfbZeroSegment
#define free_pixman_pict wfb_free_pixman_pict
#define image_from_pict wfb_image_from_pict
-#define xxScrPrivateIndex wfbxxScrPrivateIndex
-#define xxGCPrivateIndex wfbxxGCPrivateIndex
-#define xxColormapPrivateIndex wfbxxColormapPrivateIndex
+#define xxScrPrivateKey wfbxxScrPrivateKey
+#define xxGCPrivateKey wfbxxGCPrivateKey
+#define xxColormapPrivateKey wfbxxColormapPrivateKey
#define xxGeneration wfbxxGeneration
#define xxPrintVisuals wfbxxPrintVisuals
#define xxGCFuncs wfbxxGCFuncs
diff --git a/hw/dmx/dmxcmap.c b/hw/dmx/dmxcmap.c
index 949d7d689..4aa586aff 100644
--- a/hw/dmx/dmxcmap.c
+++ b/hw/dmx/dmxcmap.c
@@ -46,24 +46,10 @@
#include "micmap.h"
-static int dmxInitColormapPrivateFunc(ColormapPtr pColormap, int index)
-{
- return TRUE;
-}
-
static Bool dmxAllocateColormapPrivates(ColormapPtr pColormap)
{
- static unsigned long dmxColormapGeneration;
dmxColormapPrivPtr pCmapPriv;
- if (dmxColormapGeneration != serverGeneration) {
- if ((dmxColormapPrivateIndex
- = AllocateColormapPrivateIndex(dmxInitColormapPrivateFunc)) < 0)
- return FALSE;
-
- dmxColormapGeneration = serverGeneration;
- }
-
pCmapPriv = (dmxColormapPrivPtr)xalloc(sizeof(*pCmapPriv));
if (!pCmapPriv)
return FALSE;
diff --git a/hw/dmx/dmxcmap.h b/hw/dmx/dmxcmap.h
index 228f8662e..f968f8622 100644
--- a/hw/dmx/dmxcmap.h
+++ b/hw/dmx/dmxcmap.h
@@ -56,15 +56,14 @@ extern Bool dmxBECreateColormap(ColormapPtr pColormap);
extern Bool dmxBEFreeColormap(ColormapPtr pColormap);
/** Private index. \see dmxcmap.c \see dmxscrinit.c \see dmxwindow.c */
-extern int dmxColormapPrivateIndex;
+extern DevPrivateKey dmxColormapPrivateKey;
/** Set colormap private structure. */
#define DMX_SET_COLORMAP_PRIV(_pCMap, _pCMapPriv) \
- (_pCMap)->devPrivates[dmxColormapPrivateIndex].ptr \
- = (pointer)(_pCMapPriv);
+ dixSetPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey, _pCMapPriv)
/** Get colormap private structure. */
-#define DMX_GET_COLORMAP_PRIV(_pCMap) \
- (dmxColormapPrivPtr)(_pCMap)->devPrivates[dmxColormapPrivateIndex].ptr
+#define DMX_GET_COLORMAP_PRIV(_pCMap) (dmxColormapPrivPtr) \
+ dixLookupPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey)
#endif /* DMXCMAP_H */
diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index 1ad199d58..8a801169c 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -662,8 +662,8 @@ static Bool _dmxRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
DMXDBG2("_dmxRealizeCursor(%d,%p)\n", pScreen->myNum, pCursor);
- pCursor->devPriv[pScreen->myNum] = xalloc(sizeof(*pCursorPriv));
- if (!pCursor->devPriv[pScreen->myNum])
+ DMX_SET_CURSOR_PRIV(pCursor, pScreen, xalloc(sizeof(*pCursorPriv)));
+ if (!DMX_GET_CURSOR_PRIV(pCursor, pScreen))
return FALSE;
pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen);
@@ -700,9 +700,9 @@ static Bool _dmxUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
if (dmxScreen->beDisplay) {
if (dmxBEFreeCursor(pScreen, pCursor))
- xfree(pCursor->devPriv[pScreen->myNum]);
+ xfree(DMX_GET_CURSOR_PRIV(pCursor, pScreen));
}
- pCursor->devPriv[pScreen->myNum] = NULL;
+ DMX_SET_CURSOR_PRIV(pCursor, pScreen, NULL);
return TRUE;
}
diff --git a/hw/dmx/dmxcursor.h b/hw/dmx/dmxcursor.h
index 7b70c6250..d909bd01e 100644
--- a/hw/dmx/dmxcursor.h
+++ b/hw/dmx/dmxcursor.h
@@ -63,7 +63,10 @@ extern void dmxHideCursor(DMXScreenInfo *dmxScreen);
extern void dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor);
extern Bool dmxBEFreeCursor(ScreenPtr pScreen, CursorPtr pCursor);
-#define DMX_GET_CURSOR_PRIV(_pCursor, _pScreen) \
- (dmxCursorPrivPtr)(_pCursor)->devPriv[(_pScreen)->myNum]
+#define DMX_GET_CURSOR_PRIV(_pCursor, _pScreen) \
+ ((dmxCursorPrivPtr)dixLookupPrivate(&(_pCursor)->devPrivates, _pScreen))
+
+#define DMX_SET_CURSOR_PRIV(_pCursor, _pScreen, v) \
+ dixSetPrivate(&(_pCursor)->devPrivates, _pScreen, v)
#endif /* DMXCURSOR_H */
diff --git a/hw/dmx/dmxdpms.c b/hw/dmx/dmxdpms.c
index 5c176dfc3..2af160556 100644
--- a/hw/dmx/dmxdpms.c
+++ b/hw/dmx/dmxdpms.c
@@ -175,9 +175,9 @@ void dmxDPMSTerm(DMXScreenInfo *dmxScreen)
void dmxDPMSWakeup(void)
{
if (screenIsSaved == SCREEN_SAVER_ON)
- SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);
+ dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
#ifdef DPMSExtension
- if (DPMSPowerLevel) DPMSSet(0);
+ if (DPMSPowerLevel) DPMSSet(serverClient, 0);
#endif
}
@@ -190,11 +190,11 @@ Bool DPMSSupported(void)
}
/** This is used by clients (e.g., xset) to set the DPMS level. */
-void DPMSSet(int level)
+int DPMSSet(ClientPtr client, int level)
{
int i;
- if (!dpmsSupported) return;
+ if (!dpmsSupported) return Success;
if (level < 0) level = DPMSModeOn;
if (level > 3) level = DPMSModeOff;
@@ -208,5 +208,6 @@ void DPMSSet(int level)
dmxSync(dmxScreen, FALSE);
}
}
+ return Success;
}
#endif
diff --git a/hw/dmx/dmxfont.c b/hw/dmx/dmxfont.c
index 500b5682a..b70f7d2df 100644
--- a/hw/dmx/dmxfont.c
+++ b/hw/dmx/dmxfont.c
@@ -66,7 +66,7 @@ static char **dmxGetFontPath(int *npaths)
char *newfp;
int len, l, i;
- paths = GetFontPath(npaths, &len);
+ GetFontPath(serverClient, npaths, &len, &paths);
newfp = xalloc(*npaths + len);
c = (unsigned char *)newfp;
@@ -194,7 +194,7 @@ static int dmxProcSetFontPath(ClientPtr client)
if (total >= 4)
return BadLength;
- tmpFontPath = GetFontPath(&nOldPaths, &lenOldPaths);
+ GetFontPath(serverClient, &nOldPaths, &lenOldPaths, &tmpFontPath);
oldFontPath = xalloc(nOldPaths + lenOldPaths);
memmove(oldFontPath, tmpFontPath, nOldPaths + lenOldPaths);
@@ -361,7 +361,8 @@ Bool dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont)
}
}
- if (SetFontPath(NULL, newnpaths, (unsigned char *)newfp, &error)) {
+ if (SetFontPath(serverClient, newnpaths, (unsigned char *)newfp,
+ &error)) {
/* Note that this should never happen since all of the
* FPEs were previously valid. */
dmxLog(dmxError, "Cannot reset the default font path.\n");
diff --git a/hw/dmx/dmxgc.c b/hw/dmx/dmxgc.c
index 981f64d0a..ce1730cff 100644
--- a/hw/dmx/dmxgc.c
+++ b/hw/dmx/dmxgc.c
@@ -82,13 +82,9 @@ static GCOps dmxGCOps = {
dmxPushPixels
};
-/** Initialize the GC on \a pScreen, which currently involves allocating
- * the GC private associated with this screen. */
+/** Initialize the GC on \a pScreen */
Bool dmxInitGC(ScreenPtr pScreen)
{
- if (!AllocateGCPrivate(pScreen, dmxGCPrivateIndex, sizeof(dmxGCPrivRec)))
- return FALSE;
-
return TRUE;
}
diff --git a/hw/dmx/dmxgc.h b/hw/dmx/dmxgc.h
index 3d49f6735..2da3ba85e 100644
--- a/hw/dmx/dmxgc.h
+++ b/hw/dmx/dmxgc.h
@@ -64,11 +64,11 @@ extern void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC);
extern Bool dmxBEFreeGC(GCPtr pGC);
/** Private index. \see dmxgc.c \see dmxscrinit.c */
-extern int dmxGCPrivateIndex;
+extern DevPrivateKey dmxGCPrivateKey;
/** Get private. */
#define DMX_GET_GC_PRIV(_pGC) \
- (dmxGCPrivPtr)(_pGC)->devPrivates[dmxGCPrivateIndex].ptr
+ (dmxGCPrivPtr)dixLookupPrivate(&(_pGC)->devPrivates, dmxGCPrivateKey)
#define DMX_GC_FUNC_PROLOGUE(_pGC) \
do { \
diff --git a/hw/dmx/dmxpict.c b/hw/dmx/dmxpict.c
index bbb744c45..37dfa10ac 100644
--- a/hw/dmx/dmxpict.c
+++ b/hw/dmx/dmxpict.c
@@ -144,8 +144,7 @@ Bool dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
if (!miPictureInit(pScreen, formats, nformats))
return FALSE;
- if (!AllocatePicturePrivate(pScreen, dmxPictPrivateIndex,
- sizeof(dmxPictPrivRec)))
+ if (!dixRequestPrivate(dmxPictPrivateKey, sizeof(dmxPictPrivRec)))
return FALSE;
ps = GetPictureScreen(pScreen);
diff --git a/hw/dmx/dmxpict.h b/hw/dmx/dmxpict.h
index c178ef39c..a81eb7d37 100644
--- a/hw/dmx/dmxpict.h
+++ b/hw/dmx/dmxpict.h
@@ -116,19 +116,19 @@ extern Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet);
extern int dmxBECreatePicture(PicturePtr pPicture);
extern Bool dmxBEFreePicture(PicturePtr pPicture);
-extern int dmxPictPrivateIndex; /**< Index for picture private data */
-extern int dmxGlyphSetPrivateIndex; /**< Index for glyphset private data */
+extern DevPrivateKey dmxPictPrivateKey; /**< Index for picture private data */
+extern DevPrivateKey dmxGlyphSetPrivateKey; /**< Index for glyphset private data */
/** Get the picture private data given a picture pointer */
#define DMX_GET_PICT_PRIV(_pPict) \
- (dmxPictPrivPtr)(_pPict)->devPrivates[dmxPictPrivateIndex].ptr
+ (dmxPictPrivPtr)dixLookupPrivate(&(_pPict)->devPrivates, dmxPictPrivateKey)
/** Set the glyphset private data given a glyphset pointer */
#define DMX_SET_GLYPH_PRIV(_pGlyph, _pPriv) \
- GlyphSetSetPrivate((_pGlyph), dmxGlyphSetPrivateIndex, (_pPriv))
+ GlyphSetSetPrivate((_pGlyph), dmxGlyphSetPrivateKey, (_pPriv))
/** Get the glyphset private data given a glyphset pointer */
#define DMX_GET_GLYPH_PRIV(_pGlyph) \
- (dmxGlyphPrivPtr)GlyphSetGetPrivate((_pGlyph), dmxGlyphSetPrivateIndex)
+ (dmxGlyphPrivPtr)GlyphSetGetPrivate((_pGlyph), dmxGlyphSetPrivateKey)
#endif /* DMXPICT_H */
diff --git a/hw/dmx/dmxpixmap.c b/hw/dmx/dmxpixmap.c
index 29162f971..66224031a 100644
--- a/hw/dmx/dmxpixmap.c
+++ b/hw/dmx/dmxpixmap.c
@@ -44,12 +44,12 @@
#include "pixmapstr.h"
#include "servermd.h"
+#include "privates.h"
/** Initialize a private area in \a pScreen for pixmap information. */
Bool dmxInitPixmap(ScreenPtr pScreen)
{
- if (!AllocatePixmapPrivate(pScreen, dmxPixPrivateIndex,
- sizeof(dmxPixPrivRec)))
+ if (!dixRequestPrivate(dmxPixPrivateKey, sizeof(dmxPixPrivRec)))
return FALSE;
return TRUE;
@@ -174,6 +174,7 @@ Bool dmxDestroyPixmap(PixmapPtr pPixmap)
dmxSync(dmxScreen, FALSE);
}
}
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
#if 0
diff --git a/hw/dmx/dmxpixmap.h b/hw/dmx/dmxpixmap.h
index 5cca7f44a..64418340c 100644
--- a/hw/dmx/dmxpixmap.h
+++ b/hw/dmx/dmxpixmap.h
@@ -58,10 +58,10 @@ extern void dmxBECreatePixmap(PixmapPtr pPixmap);
extern Bool dmxBEFreePixmap(PixmapPtr pPixmap);
/** Private index. \see dmxpicmap.h \see dmxscrinit.c */
-extern int dmxPixPrivateIndex;
+extern DevPrivateKey dmxPixPrivateKey;
/** Get pixmap private pointer. */
#define DMX_GET_PIXMAP_PRIV(_pPix) \
- (dmxPixPrivPtr)(_pPix)->devPrivates[dmxPixPrivateIndex].ptr
+ (dmxPixPrivPtr)dixLookupPrivate(&(_pPix)->devPrivates, dmxPixPrivateKey)
#endif /* DMXPIXMAP_H */
diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c
index a78e3ae8d..1d12ec32d 100644
--- a/hw/dmx/dmxscrinit.c
+++ b/hw/dmx/dmxscrinit.c
@@ -67,15 +67,15 @@ static Bool dmxSaveScreen(ScreenPtr pScreen, int what);
static unsigned long dmxGeneration;
static unsigned long *dmxCursorGeneration;
-int dmxGCPrivateIndex; /**< Private index for GCs */
-int dmxWinPrivateIndex; /**< Private index for Windows */
-int dmxPixPrivateIndex; /**< Private index for Pixmaps */
+DevPrivateKey dmxGCPrivateKey = &dmxGCPrivateKey; /**< Private index for GCs */
+DevPrivateKey dmxWinPrivateKey = &dmxWinPrivateKey; /**< Private index for Windows */
+DevPrivateKey dmxPixPrivateKey = &dmxPixPrivateKey; /**< Private index for Pixmaps */
int dmxFontPrivateIndex; /**< Private index for Fonts */
-int dmxScreenPrivateIndex; /**< Private index for Screens */
-int dmxColormapPrivateIndex; /**< Private index for Colormaps */
+DevPrivateKey dmxScreenPrivateKey = &dmxScreenPrivateKey; /**< Private index for Screens */
+DevPrivateKey dmxColormapPrivateKey = &dmxColormapPrivateKey; /**< Private index for Colormaps */
#ifdef RENDER
-int dmxPictPrivateIndex; /**< Private index for Picts */
-int dmxGlyphSetPrivateIndex; /**< Private index for GlyphSets */
+DevPrivateKey dmxPictPrivateKey = &dmxPictPrivateKey; /**< Private index for Picts */
+DevPrivateKey dmxGlyphSetPrivateKey = &dmxGlyphSetPrivateKey; /**< Private index for GlyphSets */
#endif
/** Initialize the parts of screen \a idx that require access to the
@@ -208,43 +208,11 @@ Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[])
int i, j;
if (dmxGeneration != serverGeneration) {
-#ifdef RENDER
- /* Allocate picture private index */
- dmxPictPrivateIndex = AllocatePicturePrivateIndex();
- if (dmxPictPrivateIndex == -1)
- return FALSE;
-
- /* Allocate glyph set private index */
- dmxGlyphSetPrivateIndex = AllocateGlyphSetPrivateIndex();
- if (dmxGlyphSetPrivateIndex == -1)
- return FALSE;
-#endif
-
- /* Allocate GC private index */
- dmxGCPrivateIndex = AllocateGCPrivateIndex();
- if (dmxGCPrivateIndex == -1)
- return FALSE;
-
- /* Allocate window private index */
- dmxWinPrivateIndex = AllocateWindowPrivateIndex();
- if (dmxWinPrivateIndex == -1)
- return FALSE;
-
- /* Allocate pixmap private index */
- dmxPixPrivateIndex = AllocatePixmapPrivateIndex();
- if (dmxPixPrivateIndex == -1)
- return FALSE;
-
/* Allocate font private index */
dmxFontPrivateIndex = AllocateFontPrivateIndex();
if (dmxFontPrivateIndex == -1)
return FALSE;
- /* Allocate screen private index */
- dmxScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (dmxScreenPrivateIndex == -1)
- return FALSE;
-
dmxGeneration = serverGeneration;
}
diff --git a/hw/dmx/dmxscrinit.h b/hw/dmx/dmxscrinit.h
index 46a0a00a4..a4642350c 100644
--- a/hw/dmx/dmxscrinit.h
+++ b/hw/dmx/dmxscrinit.h
@@ -41,7 +41,7 @@
#include "scrnintstr.h"
/** Private index. \see dmxscrrinit.c \see input/dmxconcole.c */
-extern int dmxScreenPrivateIndex;
+extern DevPrivateKey dmxScreenPrivateKey;
extern Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[]);
diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index 7ccecfb5b..7494e6df2 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -64,8 +64,7 @@ static void dmxDoSetShape(WindowPtr pWindow);
/** Initialize the private area for the window functions. */
Bool dmxInitWindow(ScreenPtr pScreen)
{
- if (!AllocateWindowPrivate(pScreen, dmxWinPrivateIndex,
- sizeof(dmxWinPrivRec)))
+ if (!dixRequestPrivate(dmxWinPrivateKey, sizeof(dmxWinPrivRec)))
return FALSE;
return TRUE;
diff --git a/hw/dmx/dmxwindow.h b/hw/dmx/dmxwindow.h
index 79f85ac3a..72c76aa3b 100644
--- a/hw/dmx/dmxwindow.h
+++ b/hw/dmx/dmxwindow.h
@@ -103,11 +103,11 @@ extern void dmxSetShape(WindowPtr pWindow);
#endif
/** Private index. \see dmxwindow.c \see dmxscrinit.c */
-extern int dmxWinPrivateIndex;
+extern DevPrivateKey dmxWinPrivateKey;
/** Get window private pointer. */
-#define DMX_GET_WINDOW_PRIV(_pWin) \
- ((dmxWinPrivPtr)(_pWin)->devPrivates[dmxWinPrivateIndex].ptr)
+#define DMX_GET_WINDOW_PRIV(_pWin) ((dmxWinPrivPtr) \
+ dixLookupPrivate(&(_pWin)->devPrivates, dmxWinPrivateKey))
/* All of these macros are only used in dmxwindow.c */
#define DMX_WINDOW_FUNC_PROLOGUE(_pGC) \
diff --git a/hw/dmx/input/dmxconsole.c b/hw/dmx/input/dmxconsole.c
index cc820a204..b2a2ec302 100644
--- a/hw/dmx/input/dmxconsole.c
+++ b/hw/dmx/input/dmxconsole.c
@@ -612,7 +612,8 @@ static Bool dmxCloseConsoleScreen(int idx, ScreenPtr pScreen)
{
myPrivate *priv, *last;
- for (last = priv = pScreen->devPrivates[dmxScreenPrivateIndex].ptr;
+ for (last = priv = (myPrivate *)dixLookupPrivate(&pScreen->devPrivates,
+ dmxScreenPrivateKey);
priv;
priv = priv->next) dmxCloseConsole(last = priv);
@@ -846,13 +847,15 @@ void dmxConsoleInit(DevicePtr pDev)
dmxConsoleDraw(priv, 1, 1);
- if (screenInfo.screens[0]->devPrivates[dmxScreenPrivateIndex].ptr)
- priv->next = (screenInfo.screens[0]
- ->devPrivates[dmxScreenPrivateIndex].ptr);
+ if (dixLookupPrivate(&screenInfo.screens[0]->devPrivates,
+ dmxScreenPrivateKey))
+ priv->next = dixLookupPrivate(&screenInfo.screens[0]->devPrivates,
+ dmxScreenPrivateKey);
else
DMX_WRAP(CloseScreen, dmxCloseConsoleScreen,
priv, screenInfo.screens[0]);
- screenInfo.screens[0]->devPrivates[dmxScreenPrivateIndex].ptr = priv;
+ dixSetPrivate(&screenInfo.screens[0]->devPrivates, dmxScreenPrivateKey,
+ priv);
}
/** Fill in the \a info structure for the specified \a pDev. Only used
diff --git a/hw/dmx/input/dmxeq.c b/hw/dmx/input/dmxeq.c
index 3e98fb799..dff0b4423 100644
--- a/hw/dmx/input/dmxeq.c
+++ b/hw/dmx/input/dmxeq.c
@@ -82,7 +82,6 @@
#ifdef XINPUT
#include <X11/extensions/XIproto.h>
#define EXTENSION_PROC_ARGS void *
-#include "extinit.h" /* For LookupDeviceIntRec */
#endif
#if DMX_EQ_DEBUG
@@ -217,8 +216,9 @@ static void dmxeqProcessXInputEvent(xEvent *xe, EventRec *e)
{
deviceKeyButtonPointer *ev = (deviceKeyButtonPointer *)xe;
int id = ev->deviceid & DEVICE_BITS;
- DeviceIntPtr pDevice = LookupDeviceIntRec(id);
+ DeviceIntPtr pDevice;
+ dixLookupDevice(&pDevice, id, serverClient, DixUnknownAccess);
if (!pDevice) {
dmxLog(dmxError, "dmxeqProcessInputEvents: id %d not found\n", id);
return;
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 282b52868..a4d995cb8 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -737,7 +737,7 @@ ephyrUpdateModifierState(unsigned int state)
int i;
CARD8 mask;
- pkeydev = (DeviceIntPtr)LookupKeyboardDevice();
+ pkeydev = inputInfo.keyboard;
if (!pkeydev)
return;
diff --git a/hw/kdrive/savage/s3draw.c b/hw/kdrive/savage/s3draw.c
index e2766df0f..da0d6849f 100644
--- a/hw/kdrive/savage/s3draw.c
+++ b/hw/kdrive/savage/s3draw.c
@@ -78,9 +78,8 @@ short s3alu[16] = {
#define PixTransStore(t) *pix_trans = (t)
#endif
-int s3GCPrivateIndex;
-int s3WindowPrivateIndex;
-int s3Generation;
+DevPrivateKey s3GCPrivateKey = &s3GCPrivateKey;
+DevPrivateKey s3WindowPrivateKey = &s3WindowPrivateKey;
/*
s3DoBitBlt
@@ -2182,7 +2181,7 @@ s3CreateWindow (WindowPtr pWin)
KdScreenPriv(pWin->drawable.pScreen);
s3ScreenInfo(pScreenPriv);
- pWin->devPrivates[s3WindowPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, s3WindowPrivateKey, NULL);
return KdCreateWindow (pWin);
}
@@ -2979,15 +2978,7 @@ s3DrawInit (ScreenPtr pScreen)
}
else
{
- if (serverGeneration != s3Generation)
- {
- s3GCPrivateIndex = AllocateGCPrivateIndex ();
- s3WindowPrivateIndex = AllocateWindowPrivateIndex ();
- s3Generation = serverGeneration;
- }
- if (!AllocateWindowPrivate(pScreen, s3WindowPrivateIndex, 0))
- return FALSE;
- if (!AllocateGCPrivate(pScreen, s3GCPrivateIndex, sizeof (s3PrivGCRec)))
+ if (!dixRequestPrivate(s3GCPrivateKey, sizeof (s3PrivGCRec)))
return FALSE;
pScreen->CreateGC = s3CreateGC;
pScreen->CreateWindow = s3CreateWindow;
diff --git a/hw/kdrive/savage/s3draw.h b/hw/kdrive/savage/s3draw.h
index 068904370..eab8e395e 100644
--- a/hw/kdrive/savage/s3draw.h
+++ b/hw/kdrive/savage/s3draw.h
@@ -24,8 +24,8 @@
#ifndef _S3DRAW_H_
#define _S3DRAW_H_
-extern int s3GCPrivateIndex;
-extern int s3WindowPrivateIndex;
+extern DevPrivateKey s3GCPrivateKey;
+extern DevPrivateKey s3WindowPrivateKey;
typedef struct _s3Pattern {
S3PatternCache *cache;
@@ -42,16 +42,16 @@ typedef struct _s3PrivGC {
s3PatternPtr pPattern; /* pattern */
} s3PrivGCRec, *s3PrivGCPtr;
-#define s3GetGCPrivate(g) ((s3PrivGCPtr) \
- (g)->devPrivates[s3GCPrivateIndex].ptr)
+#define s3GetGCPrivate(g) ((s3PrivGCPtr) \
+ dixLookupPrivate(&(g)->devPrivates, s3GCPrivateKey))
-#define s3GCPrivate(g) s3PrivGCPtr s3Priv = s3GetGCPrivate(g)
+#define s3GCPrivate(g) s3PrivGCPtr s3Priv = s3GetGCPrivate(g)
-#define s3GetWindowPrivate(w) ((s3PatternPtr) \
- (w)->devPrivates[s3WindowPrivateIndex].ptr)
+#define s3GetWindowPrivate(w) ((s3PatternPtr) \
+ dixLookupPrivate(&(w)->devPrivates, s3WindowPrivateKey))
-#define s3SetWindowPrivate(w,p) (\
- (w)->devPrivates[s3WindowPrivateIndex].ptr = (pointer) p)
+#define s3SetWindowPrivate(w,p) \
+ dixSetPrivate(&(w)->devPrivates, s3WindowPrivateKey, p)
void _s3LoadPattern (ScreenPtr pScreen, int fb, s3PatternPtr pPattern);
diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c
index 027163024..e75b08399 100644
--- a/hw/kdrive/src/kaa.c
+++ b/hw/kdrive/src/kaa.c
@@ -42,9 +42,8 @@
#define DBG_PIXMAP(a)
#endif
-int kaaGeneration;
-int kaaScreenPrivateIndex;
-int kaaPixmapPrivateIndex;
+DevPrivateKey kaaScreenPrivateKey = &kaaScreenPrivateKey;
+DevPrivateKey kaaPixmapPrivateKey = &kaaPixmapPrivateKey;
#define KAA_PIXMAP_SCORE_MOVE_IN 10
#define KAA_PIXMAP_SCORE_MAX 20
@@ -1020,13 +1019,6 @@ kaaDrawInit (ScreenPtr pScreen,
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- if (kaaGeneration != serverGeneration)
- {
- kaaScreenPrivateIndex = AllocateScreenPrivateIndex();
- kaaPixmapPrivateIndex = AllocatePixmapPrivateIndex();
- kaaGeneration = serverGeneration;
- }
-
pKaaScr = xalloc (sizeof (KaaScreenPrivRec));
if (!pKaaScr)
@@ -1034,7 +1026,7 @@ kaaDrawInit (ScreenPtr pScreen,
pKaaScr->info = pScreenInfo;
- pScreen->devPrivates[kaaScreenPrivateIndex].ptr = (pointer) pKaaScr;
+ dixSetPrivate(&pScreen->devPrivates, kaaScreenPrivateKey, pKaaScr);
/*
* Hook up asynchronous drawing
@@ -1058,17 +1050,11 @@ kaaDrawInit (ScreenPtr pScreen,
if ((pKaaScr->info->flags & KAA_OFFSCREEN_PIXMAPS) &&
screen->off_screen_base < screen->memory_size)
{
- if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex,
- sizeof (KaaPixmapPrivRec)))
+ if (!dixRequestPrivate(kaaPixmapPrivateKey, sizeof (KaaPixmapPrivRec)))
return FALSE;
pScreen->CreatePixmap = kaaCreatePixmap;
pScreen->DestroyPixmap = kaaDestroyPixmap;
}
- else
- {
- if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex, 0))
- return FALSE;
- }
return TRUE;
}
diff --git a/hw/kdrive/src/kaa.h b/hw/kdrive/src/kaa.h
index db890a75b..90b963b10 100644
--- a/hw/kdrive/src/kaa.h
+++ b/hw/kdrive/src/kaa.h
@@ -27,11 +27,14 @@
#include "picturestr.h"
-#define KaaGetScreenPriv(s) ((KaaScreenPrivPtr)(s)->devPrivates[kaaScreenPrivateIndex].ptr)
+#define KaaGetScreenPriv(s) ((KaaScreenPrivPtr) \
+ dixLookupPrivate(&(s)->devPrivates, kaaScreenPrivateKey))
#define KaaScreenPriv(s) KaaScreenPrivPtr pKaaScr = KaaGetScreenPriv(s)
-#define KaaGetPixmapPriv(p) ((KaaPixmapPrivPtr)(p)->devPrivates[kaaPixmapPrivateIndex].ptr)
-#define KaaSetPixmapPriv(p,a) ((p)->devPrivates[kaaPixmapPrivateIndex].ptr = (pointer) (a))
+#define KaaGetPixmapPriv(p) ((KaaPixmapPrivPtr) \
+ dixLookupPrivate(&(p)->devPrivates, kaaPixmapPrivateKey))
+#define KaaSetPixmapPriv(p,a) \
+ dixSetPrivate(&(p)->devPrivates, kaaPixmapPrivateKey, a)
#define KaaPixmapPriv(p) KaaPixmapPrivPtr pKaaPixmap = KaaGetPixmapPriv(p)
typedef struct {
@@ -46,8 +49,8 @@ typedef struct {
Bool dirty;
} KaaPixmapPrivRec, *KaaPixmapPrivPtr;
-extern int kaaScreenPrivateIndex;
-extern int kaaPixmapPrivateIndex;
+extern DevPrivateKey kaaScreenPrivateKey;
+extern DevPrivateKey kaaPixmapPrivateKey;
void
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 2fde66c4d..8722ba303 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -498,7 +498,7 @@ typedef struct _KaaScreenInfo {
(PixmapWidthPaddingInfo[d].padRoundUp+1)))
#endif
-extern int kdScreenPrivateIndex;
+extern DevPrivateKey kdScreenPrivateKey;
extern unsigned long kdGeneration;
extern Bool kdEnabled;
extern Bool kdSwitchPending;
@@ -510,9 +510,9 @@ extern char *kdSwitchCmd;
extern KdOsFuncs *kdOsFuncs;
#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
- (pScreen)->devPrivates[kdScreenPrivateIndex].ptr)
-#define KdSetScreenPriv(pScreen,v) ((pScreen)->devPrivates[kdScreenPrivateIndex].ptr = \
- (pointer) v)
+ dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey))
+#define KdSetScreenPriv(pScreen,v) \
+ dixSetPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey, v)
#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen)
/* kaa.c */
diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index 046ab27b3..b6ff4f831 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -104,23 +104,22 @@ static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int);
-int KdXVWindowIndex = -1;
-int KdXvScreenIndex = -1;
-static unsigned long KdXVGeneration = 0;
+DevPrivateKey KdXVWindowKey = &KdXVWindowKey;
+DevPrivateKey KdXvScreenKey = &KdXvScreenKey;
static unsigned long PortResource = 0;
-int (*XvGetScreenIndexProc)(void) = XvGetScreenIndex;
+int (*XvGetScreenKeyProc)(void) = XvGetScreenKey;
unsigned long (*XvGetRTPortProc)(void) = XvGetRTPort;
int (*XvScreenInitProc)(ScreenPtr) = XvScreenInit;
-#define GET_XV_SCREEN(pScreen) \
- ((XvScreenPtr)((pScreen)->devPrivates[KdXvScreenIndex].ptr))
+#define GET_XV_SCREEN(pScreen) ((XvScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, KdXvScreenKey))
#define GET_KDXV_SCREEN(pScreen) \
((KdXVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
-#define GET_KDXV_WINDOW(pWin) \
- ((KdXVWindowPtr)((pWin)->devPrivates[KdXVWindowIndex].ptr))
+#define GET_KDXV_WINDOW(pWin) ((KdXVWindowPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, KdXVWindowKey))
static KdXVInitGenericAdaptorPtr *GenDrivers = NULL;
static int NumGenDrivers = 0;
@@ -192,21 +191,12 @@ KdXVScreenInit(
/* fprintf(stderr,"KdXVScreenInit initializing %d adaptors\n",num); */
- if(KdXVGeneration != serverGeneration) {
- if((KdXVWindowIndex = AllocateWindowPrivateIndex()) < 0)
- return FALSE;
- KdXVGeneration = serverGeneration;
- }
-
- if(!AllocateWindowPrivate(pScreen,KdXVWindowIndex,0))
- return FALSE;
-
- if(!XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc)
+ if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
return FALSE;
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
- KdXvScreenIndex = (*XvGetScreenIndexProc)();
+ KdXvScreenIndex = (*XvGetScreenKeyProc)();
PortResource = (*XvGetRTPortProc)();
pxvs = GET_XV_SCREEN(pScreen);
@@ -938,7 +928,7 @@ KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
if(!winPriv) return BadAlloc;
winPriv->PortRec = portPriv;
winPriv->next = PrivRoot;
- pWin->devPrivates[KdXVWindowIndex].ptr = (pointer)winPriv;
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv);
}
return Success;
}
@@ -956,8 +946,7 @@ KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
if(prevPriv)
prevPriv->next = winPriv->next;
else
- pWin->devPrivates[KdXVWindowIndex].ptr =
- (pointer)winPriv->next;
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next);
xfree(winPriv);
break;
}
@@ -981,7 +970,8 @@ KdXVCreateWindow(WindowPtr pWin)
ret = (*pScreen->CreateWindow)(pWin);
pScreen->CreateWindow = KdXVCreateWindow;
- if(ret) pWin->devPrivates[KdXVWindowIndex].ptr = NULL;
+ if (ret)
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
return ret;
}
@@ -1010,7 +1000,7 @@ KdXVDestroyWindow(WindowPtr pWin)
xfree(tmp);
}
- pWin->devPrivates[KdXVWindowIndex].ptr = NULL;
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
ret = (*pScreen->DestroyWindow)(pWin);
@@ -1067,8 +1057,7 @@ KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[KdXVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
@@ -1117,8 +1106,7 @@ KdXVClipNotify(WindowPtr pWin, int dx, int dy)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[KdXVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
diff --git a/hw/kdrive/vxworks/vxkbd.c b/hw/kdrive/vxworks/vxkbd.c
index be528c78a..ac83ef729 100644
--- a/hw/kdrive/vxworks/vxkbd.c
+++ b/hw/kdrive/vxworks/vxkbd.c
@@ -232,7 +232,7 @@ VxWorksKeyboardRead (int fd)
void
VxWorksKeyboardLeds (int leds)
{
- DeviceIntPtr pKeyboard = (DeviceIntPtr) LookupKeyboardDevice ();
+ DeviceIntPtr pKeyboard = inputInfo.keyboard;
KeyboardCtrl *ctrl = &pKeyboard->kbdfeed->ctrl;
led_ioctl_info led_info;
int i;
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 64449482f..4e7d914bf 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -57,9 +57,9 @@
/* General parameters */
extern int xf86DoConfigure;
extern Bool xf86DoConfigurePass1;
-extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */
-extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */
-extern int xf86PixmapIndex;
+extern DevPrivateKey xf86ScreenKey;
+extern DevPrivateKey xf86CreateRootWindowKey;
+extern DevPrivateKey xf86PixmapKey;
extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
extern const unsigned char byte_reversed[256];
extern ScrnInfoPtr xf86CurrentScreen;
@@ -72,8 +72,8 @@ extern Bool sbusSlotClaimed;
extern confDRIRec xf86ConfigDRI;
extern Bool xf86inSuspend;
-#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr))
-
+#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
+ xf86ScreenKey))
#define XF86FLIP_PIXELS() \
do { \
if (xf86GetFlipPixels()) { \
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 85d4b2ea0..0daf1de44 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -49,8 +49,7 @@
#include "mi.h"
-static unsigned long DGAGeneration = 0;
-static int DGAScreenIndex = -1;
+static DevPrivateKey DGAScreenKey = NULL;
static int mieq_installed = 0;
static Bool DGACloseScreen(int i, ScreenPtr pScreen);
@@ -68,8 +67,8 @@ DGACopyModeInfo(
_X_EXPORT int *XDGAEventBase = NULL;
-#define DGA_GET_SCREEN_PRIV(pScreen) \
- ((DGAScreenPtr)((pScreen)->devPrivates[DGAScreenIndex].ptr))
+#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey))
typedef struct _FakedVisualList{
@@ -116,11 +115,7 @@ DGAInit(
if(!modes || num <= 0)
return FALSE;
- if(DGAGeneration != serverGeneration) {
- if((DGAScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- DGAGeneration = serverGeneration;
- }
+ DGAScreenKey = &DGAScreenKey;
if(!(pScreenPriv = (DGAScreenPtr)xalloc(sizeof(DGAScreenRec))))
return FALSE;
@@ -148,7 +143,7 @@ DGAInit(
modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
#endif
- pScreen->devPrivates[DGAScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = DGACloseScreen;
pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
@@ -176,7 +171,7 @@ DGAReInitModes(
int i;
/* No DGA? Ignore call (but don't make it look like it failed) */
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return TRUE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@@ -350,7 +345,7 @@ xf86SetDGAMode(
DGAModePtr pMode = NULL;
/* First check if DGAInit was successful on this screen */
- if (DGAScreenIndex < 0)
+ if (DGAScreenKey == NULL)
return BadValue;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if (!pScreenPriv)
@@ -485,7 +480,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
DGAModePtr pMode;
PixmapPtr pPix;
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -535,11 +530,12 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
_X_EXPORT Bool
DGAAvailable(int index)
{
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return FALSE;
- if (!xf86NoSharedResources(((ScrnInfoPtr)screenInfo.screens[index]->
- devPrivates[xf86ScreenIndex].ptr)->scrnIndex,MEM))
+ if (!xf86NoSharedResources(((ScrnInfoPtr)dixLookupPrivate(
+ &screenInfo.screens[index]->devPrivates,
+ xf86ScreenKey))->scrnIndex, MEM))
return FALSE;
if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
@@ -553,7 +549,7 @@ DGAActive(int index)
{
DGAScreenPtr pScreenPriv;
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -574,7 +570,7 @@ DGAShutdown()
ScrnInfoPtr pScrn;
int i;
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return;
for(i = 0; i < screenInfo.numScreens; i++) {
@@ -904,7 +900,7 @@ DGAVTSwitch(void)
/* Alternatively, this could send events to DGA clients */
- if(DGAScreenIndex >= 0) {
+ if(DGAScreenKey) {
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if(pScreenPriv && pScreenPriv->current)
@@ -921,7 +917,7 @@ DGAStealKeyEvent(int index, int key_code, int is_down)
DGAScreenPtr pScreenPriv;
dgaEvent de;
- if(DGAScreenIndex < 0) /* no DGA */
+ if(DGAScreenKey == NULL) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -945,7 +941,7 @@ DGAStealMotionEvent(int index, int dx, int dy)
DGAScreenPtr pScreenPriv;
dgaEvent de;
- if(DGAScreenIndex < 0) /* no DGA */
+ if(DGAScreenKey == NULL) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -980,7 +976,7 @@ DGAStealButtonEvent(int index, int button, int is_down)
DGAScreenPtr pScreenPriv;
dgaEvent de;
- if (DGAScreenIndex < 0)
+ if (DGAScreenKey == NULL)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -1006,7 +1002,7 @@ Bool
DGAIsDgaEvent (xEvent *e)
{
int coreEquiv;
- if (DGAScreenIndex < 0 || XDGAEventBase == 0)
+ if (DGAScreenKey == NULL || XDGAEventBase == 0)
return FALSE;
coreEquiv = e->u.u.type - *XDGAEventBase;
if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
@@ -1275,7 +1271,7 @@ DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents)
int coreEquiv;
/* no DGA */
- if (DGAScreenIndex < 0 || XDGAEventBase == 0)
+ if (DGAScreenKey == NULL || XDGAEventBase == 0)
return;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c
index 3aa83e882..43efb8ed4 100644
--- a/hw/xfree86/common/xf86DPMS.c
+++ b/hw/xfree86/common/xf86DPMS.c
@@ -47,8 +47,7 @@
#ifdef DPMSExtension
-static int DPMSGeneration = 0;
-static int DPMSIndex = -1;
+static DevPrivateKey DPMSKey = NULL;
static Bool DPMSClose(int i, ScreenPtr pScreen);
static int DPMSCount = 0;
#endif
@@ -62,18 +61,15 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
DPMSPtr pDPMS;
pointer DPMSOpt;
- if (serverGeneration != DPMSGeneration) {
- if ((DPMSIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- DPMSGeneration = serverGeneration;
- }
+ DPMSKey = &DPMSKey;
if (DPMSDisabledSwitch)
DPMSEnabled = FALSE;
- if (!(pScreen->devPrivates[DPMSIndex].ptr = xcalloc(sizeof(DPMSRec), 1)))
+ if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey,
+ xcalloc(sizeof(DPMSRec), 1)))
return FALSE;
- pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
pScrn->DPMSSet = set;
pDPMS->Flags = flags;
DPMSOpt = xf86FindOption(pScrn->options, "dpms");
@@ -110,10 +106,10 @@ DPMSClose(int i, ScreenPtr pScreen)
DPMSPtr pDPMS;
/* This shouldn't happen */
- if (DPMSIndex < 0)
+ if (DPMSKey == NULL)
return FALSE;
- pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
/* This shouldn't happen */
if (!pDPMS)
@@ -132,9 +128,9 @@ DPMSClose(int i, ScreenPtr pScreen)
}
xfree((pointer)pDPMS);
- pScreen->devPrivates[DPMSIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL);
if (--DPMSCount == 0)
- DPMSIndex = -1;
+ DPMSKey = NULL;
return pScreen->CloseScreen(i, pScreen);
}
@@ -144,30 +140,35 @@ DPMSClose(int i, ScreenPtr pScreen)
* Device dependent DPMS mode setting hook. This is called whenever
* the DPMS mode is to be changed.
*/
-_X_EXPORT void
-DPMSSet(int level)
+_X_EXPORT int
+DPMSSet(ClientPtr client, int level)
{
- int i;
+ int rc, i;
DPMSPtr pDPMS;
ScrnInfoPtr pScrn;
DPMSPowerLevel = level;
- if (DPMSIndex < 0)
- return;
+ if (DPMSKey == NULL)
+ return Success;
- if (level != DPMSModeOn)
- SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverActive);
+ if (level != DPMSModeOn) {
+ rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverActive);
+ if (rc != Success)
+ return rc;
+ }
/* For each screen, set the DPMS level */
for (i = 0; i < xf86NumScreens; i++) {
pScrn = xf86Screens[i];
- pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
+ DPMSKey);
if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) {
xf86EnableAccess(pScrn);
pScrn->DPMSSet(pScrn, level, 0);
}
}
+ return Success;
}
@@ -182,14 +183,15 @@ DPMSSupported(void)
DPMSPtr pDPMS;
ScrnInfoPtr pScrn;
- if (DPMSIndex < 0) {
+ if (DPMSKey == NULL) {
return FALSE;
}
/* For each screen, check if DPMS is supported */
for (i = 0; i < xf86NumScreens; i++) {
pScrn = xf86Screens[i];
- pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
+ DPMSKey);
if (pDPMS && pScrn->DPMSSet)
return TRUE;
}
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index e88fc3b3e..2b7cb121d 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -857,7 +857,7 @@ xf86VTSwitch()
#endif
#ifdef DPMSExtension
if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(DPMSModeOn);
+ DPMSSet(serverClient, DPMSModeOn);
#endif
for (i = 0; i < xf86NumScreens; i++) {
if (!(dispatchException & DE_TERMINATE))
@@ -906,7 +906,7 @@ xf86VTSwitch()
(*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
}
}
- SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
pInfo = xf86InputDevs;
while (pInfo) {
@@ -970,7 +970,7 @@ xf86VTSwitch()
}
/* Turn screen saver off when switching back */
- SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
pInfo = xf86InputDevs;
while (pInfo) {
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index b3969b102..d796d627c 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -46,10 +46,12 @@
/* Globals that video drivers may access */
-_X_EXPORT int xf86ScreenIndex = -1; /* Index of ScrnInfo in pScreen.devPrivates */
-int xf86CreateRootWindowIndex = -1; /* Index into pScreen.devPrivates */
+/* Index into pScreen.devPrivates */
+DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKey;
+/* Index of ScrnInfo in pScreen.devPrivates */
+_X_EXPORT DevPrivateKey xf86ScreenKey = &xf86ScreenKey;
+_X_EXPORT DevPrivateKey xf86PixmapKey = &xf86PixmapKey;
_X_EXPORT ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
-_X_EXPORT int xf86PixmapIndex = 0;
_X_EXPORT const unsigned char byte_reversed[256] =
{
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index c72fe30e8..d12b6bd6a 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -139,8 +139,8 @@ xf86CreateRootWindow(WindowPtr pWin)
int err = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
RootWinPropPtr pProp;
- CreateWindowProcPtr CreateWindow =
- (CreateWindowProcPtr)(pScreen->devPrivates[xf86CreateRootWindowIndex].ptr);
+ CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
+ dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
#ifdef DEBUG
ErrorF("xf86CreateRootWindow(%p)\n", pWin);
@@ -156,7 +156,7 @@ xf86CreateRootWindow(WindowPtr pWin)
/* Unhook this function ... */
pScreen->CreateWindow = CreateWindow;
- pScreen->devPrivates[xf86CreateRootWindowIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
/* ... and call the previous CreateWindow fuction, if any */
if (NULL!=pScreen->CreateWindow) {
@@ -476,7 +476,6 @@ void
InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
{
int i, j, k, scr_index;
- static unsigned long generation = 0;
char **modulelist;
pointer *optionlist;
screenLayoutPtr layout;
@@ -487,14 +486,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
xf86Initialising = TRUE;
- /* Do this early? */
- if (generation != serverGeneration) {
- xf86ScreenIndex = AllocateScreenPrivateIndex();
- xf86CreateRootWindowIndex = AllocateScreenPrivateIndex();
- xf86PixmapIndex = AllocatePixmapPrivateIndex();
- generation = serverGeneration;
- }
-
if (serverGeneration == 1) {
pScreenInfo->numScreens = 0;
@@ -1070,8 +1061,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
* Hook in our ScrnInfoRec, and initialise some other pScreen
* fields.
*/
- screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr
- = (pointer)xf86Screens[i];
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86ScreenKey, xf86Screens[i]);
xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
/* The driver should set this, but make sure it is set anyway */
xf86Screens[i]->vtSema = TRUE;
@@ -1087,8 +1078,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
i, xf86Screens[i]->pScreen->CreateWindow );
#endif
- screenInfo.screens[scr_index]->devPrivates[xf86CreateRootWindowIndex].ptr
- = (void*)(xf86Screens[i]->pScreen->CreateWindow);
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86CreateRootWindowKey,
+ xf86Screens[i]->pScreen->CreateWindow);
xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
#ifdef RENDER
@@ -1307,7 +1299,7 @@ AbortDDX()
*/
#ifdef DPMSExtension /* Turn screens back on */
if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(DPMSModeOn);
+ DPMSSet(serverClient, DPMSModeOn);
#endif
if (xf86Screens) {
if (xf86Screens[0]->vtSema)
diff --git a/hw/xfree86/common/xf86PM.c b/hw/xfree86/common/xf86PM.c
index a6bcc3421..7c8320dee 100644
--- a/hw/xfree86/common/xf86PM.c
+++ b/hw/xfree86/common/xf86PM.c
@@ -116,7 +116,7 @@ resume(pmEvent event, Bool undo)
if (xf86Screens[i]->EnableDisableFBAccess)
(*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
}
- SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
pInfo = xf86InputDevs;
while (pInfo) {
EnableDevice(pInfo->dev);
diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
index 288d72193..4432ad96b 100644
--- a/hw/xfree86/common/xf86RandR.c
+++ b/hw/xfree86/common/xf86RandR.c
@@ -45,10 +45,9 @@ typedef struct _xf86RandRInfo {
Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr;
-static int xf86RandRIndex = -1;
-static int xf86RandRGeneration;
+static DevPrivateKey xf86RandRKey = NULL;
-#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[xf86RandRIndex].ptr)
+#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
static int
xf86RandRModeRefresh (DisplayModePtr mode)
@@ -338,14 +337,14 @@ xf86RandRCloseScreen (int index, ScreenPtr pScreen)
scrp->currentMode = scrp->modes;
pScreen->CloseScreen = randrp->CloseScreen;
xfree (randrp);
- pScreen->devPrivates[xf86RandRIndex].ptr = 0;
+ dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL);
return (*pScreen->CloseScreen) (index, pScreen);
}
_X_EXPORT Rotation
xf86GetRotation(ScreenPtr pScreen)
{
- if (xf86RandRIndex == -1)
+ if (xf86RandRKey == NULL)
return RR_Rotate_0;
return XF86RANDRINFO(pScreen)->rotation;
@@ -359,7 +358,7 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
{
XF86RandRInfoPtr randrp;
- if (xf86RandRIndex == -1)
+ if (xf86RandRKey == NULL)
return FALSE;
randrp = XF86RANDRINFO(pScreen);
@@ -401,11 +400,8 @@ xf86RandRInit (ScreenPtr pScreen)
if (!noPanoramiXExtension)
return TRUE;
#endif
- if (xf86RandRGeneration != serverGeneration)
- {
- xf86RandRIndex = AllocateScreenPrivateIndex();
- xf86RandRGeneration = serverGeneration;
- }
+
+ xf86RandRKey = &xf86RandRKey;
randrp = xalloc (sizeof (XF86RandRInfoRec));
if (!randrp)
@@ -433,7 +429,7 @@ xf86RandRInit (ScreenPtr pScreen)
randrp->rotation = RR_Rotate_0;
- pScreen->devPrivates[xf86RandRIndex].ptr = randrp;
+ dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp);
return TRUE;
}
diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c
index 16a4d824c..38d605c88 100644
--- a/hw/xfree86/common/xf86VidMode.c
+++ b/hw/xfree86/common/xf86VidMode.c
@@ -47,12 +47,11 @@
#include "vidmodeproc.h"
#include "xf86cmap.h"
-static int VidModeGeneration = 0;
-static int VidModeIndex = -1;
+static DevPrivateKey VidModeKey = NULL;
static int VidModeCount = 0;
static Bool VidModeClose(int i, ScreenPtr pScreen);
-#define VMPTR(p) ((VidModePtr)(p)->devPrivates[VidModeIndex].ptr)
+#define VMPTR(p) ((VidModePtr)dixLookupPrivate(&(p)->devPrivates, VidModeKey))
#endif
@@ -73,15 +72,10 @@ VidModeExtensionInit(ScreenPtr pScreen)
return FALSE;
}
- if (serverGeneration != VidModeGeneration) {
- if ((VidModeIndex = AllocateScreenPrivateIndex()) < 0) {
- DEBUG_P("AllocateScreenPrivateIndex() failed");
- return FALSE;
- }
- VidModeGeneration = serverGeneration;
- }
+ VidModeKey = &VidModeKey;
- if (!(pScreen->devPrivates[VidModeIndex].ptr = xcalloc(sizeof(VidModeRec), 1))) {
+ if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey,
+ xcalloc(sizeof(VidModeRec), 1))) {
DEBUG_P("xcalloc failed");
return FALSE;
}
@@ -114,10 +108,9 @@ VidModeClose(int i, ScreenPtr pScreen)
pScreen->CloseScreen = pVidMode->CloseScreen;
if (--VidModeCount == 0) {
- if (pScreen->devPrivates[VidModeIndex].ptr)
- xfree(pScreen->devPrivates[VidModeIndex].ptr);
- pScreen->devPrivates[VidModeIndex].ptr = NULL;
- VidModeIndex = -1;
+ xfree(dixLookupPrivate(&pScreen->devPrivates, VidModeKey));
+ dixSetPrivate(&pScreen->devPrivates, VidModeKey, NULL);
+ VidModeKey = NULL;
}
return pScreen->CloseScreen(i, pScreen);
}
@@ -128,8 +121,8 @@ VidModeAvailable(int scrnIndex)
ScrnInfoPtr pScrn;
VidModePtr pVidMode;
- if (VidModeIndex < 0) {
- DEBUG_P("VidModeIndex < 0");
+ if (VidModeKey == NULL) {
+ DEBUG_P("VidModeKey == NULL");
return FALSE;
}
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index b939fb763..cd0c30ac1 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -77,7 +77,6 @@
#define EXTENSION_PROC_ARGS void *
#include "extnsionst.h"
-#include "extinit.h" /* LookupDeviceIntRec */
#include "windowstr.h" /* screenIsSaved */
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index ea6a26dcd..764647ee4 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -60,7 +60,7 @@
#include "xf86cmap.h"
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
- ((CMapScreenPtr) (pScreen)->devPrivates[CMapScreenIndex].ptr)->field)
+ ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field)
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
@@ -102,9 +102,8 @@ typedef struct {
int overscan;
} CMapColormapRec, *CMapColormapPtr;
-static unsigned long CMapGeneration = 0;
-static int CMapScreenIndex = -1;
-static int CMapColormapIndex = -1;
+static DevPrivateKey CMapScreenKey = NULL;
+static DevPrivateKey CMapColormapKey = &CMapColormapKey;
static void CMapInstallColormap(ColormapPtr);
static void CMapStoreColors(ColormapPtr, int, xColorItem *);
@@ -119,7 +118,6 @@ static int CMapChangeGamma(int, Gamma);
static void ComputeGamma(CMapScreenPtr);
static Bool CMapAllocateColormapPrivate(ColormapPtr);
-static Bool CMapInitDefMap(ColormapPtr,int);
static void CMapRefreshColors(ColormapPtr, int, int*);
static void CMapSetOverscan(ColormapPtr, int, int *);
static void CMapReinstallMap(ColormapPtr);
@@ -145,13 +143,7 @@ _X_EXPORT Bool xf86HandleColormaps(
if(!maxColors || !sigRGBbits || !loadPalette)
return FALSE;
- if(CMapGeneration != serverGeneration) {
- if(((CMapScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((CMapColormapIndex = AllocateColormapPrivateIndex(
- CMapInitDefMap)) < 0))
- return FALSE;
- CMapGeneration = serverGeneration;
- }
+ CMapScreenKey = &CMapScreenKey;
elements = 1 << sigRGBbits;
@@ -169,7 +161,7 @@ _X_EXPORT Bool xf86HandleColormaps(
return FALSE;
}
- pScreen->devPrivates[CMapScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreenPriv->CreateColormap = pScreen->CreateColormap;
@@ -225,12 +217,6 @@ _X_EXPORT Bool xf86HandleColormaps(
return TRUE;
}
-static Bool
-CMapInitDefMap(ColormapPtr cmap, int index)
-{
- return TRUE;
-}
-
/**** Screen functions ****/
@@ -254,8 +240,8 @@ CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv)
static Bool
CMapAllocateColormapPrivate(ColormapPtr pmap)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
CMapColormapPtr pColPriv;
CMapLinkPtr pLink;
int numColors;
@@ -274,7 +260,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap)
return FALSE;
}
- pmap->devPrivates[CMapColormapIndex].ptr = (pointer)pColPriv;
+ dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv);
pColPriv->numColors = numColors;
pColPriv->colors = colors;
@@ -296,8 +282,8 @@ static Bool
CMapCreateColormap (ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
Bool ret = FALSE;
pScreen->CreateColormap = pScreenPriv->CreateColormap;
@@ -314,10 +300,10 @@ static void
CMapDestroyColormap (ColormapPtr cmap)
{
ScreenPtr pScreen = cmap->pScreen;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) cmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &cmap->devPrivates, CMapColormapKey);
CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
if(pColPriv) {
@@ -356,8 +342,8 @@ CMapStoreColors(
){
ScreenPtr pScreen = pmap->pScreen;
VisualPtr pVisual = pmap->pVisual;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
int *indices = pScreenPriv->PreAllocIndices;
int num = ndef;
@@ -373,8 +359,8 @@ CMapStoreColors(
return;
if(pVisual->class == DirectColor) {
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
int i;
if (CMapColormapUseMax(pVisual, pScreenPriv)) {
@@ -431,8 +417,8 @@ CMapInstallColormap(ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
int index = pScreen->myNum;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
if (pmap == miInstalledMaps[index])
return;
@@ -462,8 +448,8 @@ static Bool
CMapEnterVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
if((*pScreenPriv->EnterVT)(index, flags)) {
if(miInstalledMaps[index])
@@ -478,8 +464,8 @@ static Bool
CMapSwitchMode(int index, DisplayModePtr mode, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
if((*pScreenPriv->SwitchMode)(index, mode, flags)) {
if(miInstalledMaps[index])
@@ -494,8 +480,8 @@ static int
CMapSetDGAMode(int index, int num, DGADevicePtr dev)
{
ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
int ret;
ret = (*pScreenPriv->SetDGAMode)(index, num, dev);
@@ -516,10 +502,10 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev)
static void
CMapReinstallMap(ColormapPtr pmap)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr cmapPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr cmapPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
int i = cmapPriv->numColors;
int *indices = pScreenPriv->PreAllocIndices;
@@ -547,10 +533,10 @@ CMapReinstallMap(ColormapPtr pmap)
static void
CMapRefreshColors(ColormapPtr pmap, int defs, int* indices)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
VisualPtr pVisual = pmap->pVisual;
ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
int numColors, i;
@@ -681,10 +667,10 @@ CMapCompareColors(LOCO *color1, LOCO *color2)
static void
CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
VisualPtr pVisual = pmap->pVisual;
int i;
@@ -819,8 +805,8 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
static void
CMapUnwrapScreen(ScreenPtr pScreen)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
pScreen->CloseScreen = pScreenPriv->CloseScreen;
@@ -904,10 +890,11 @@ CMapChangeGamma(
CMapLinkPtr pLink;
/* Is this sufficient checking ? */
- if(CMapScreenIndex == -1)
+ if(CMapScreenKey == NULL)
return BadImplementation;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv)
return BadImplementation;
@@ -925,8 +912,8 @@ CMapChangeGamma(
/* mark all colormaps on this screen */
pLink = pScreenPriv->maps;
while(pLink) {
- pColPriv =
- (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr;
+ pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
pColPriv->recalculate = TRUE;
pLink = pLink->next;
}
@@ -997,10 +984,11 @@ xf86ChangeGammaRamp(
CMapScreenPtr pScreenPriv;
CMapLinkPtr pLink;
- if(CMapScreenIndex == -1)
+ if(CMapScreenKey == NULL)
return BadImplementation;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv)
return BadImplementation;
@@ -1012,8 +1000,8 @@ xf86ChangeGammaRamp(
/* mark all colormaps on this screen */
pLink = pScreenPriv->maps;
while(pLink) {
- pColPriv =
- (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr;
+ pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
pColPriv->recalculate = TRUE;
pLink = pLink->next;
}
@@ -1056,9 +1044,10 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
{
CMapScreenPtr pScreenPriv;
- if(CMapScreenIndex == -1) return 0;
+ if(CMapScreenKey == NULL) return 0;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv) return 0;
return pScreenPriv->gammaElements;
@@ -1076,10 +1065,11 @@ xf86GetGammaRamp(
LOCO *entry;
int shift, sigbits;
- if(CMapScreenIndex == -1)
+ if(CMapScreenKey == NULL)
return BadImplementation;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv)
return BadImplementation;
diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c
index 537d53d7d..9fd2e6c70 100644
--- a/hw/xfree86/common/xf86fbman.c
+++ b/hw/xfree86/common/xf86fbman.c
@@ -42,21 +42,15 @@
#define DEBUG
*/
-static int xf86FBMangerIndex = -1;
-static unsigned long xf86ManagerGeneration = 0;
+static DevPrivateKey xf86FBManagerKey = NULL;
_X_EXPORT Bool xf86RegisterOffscreenManager(
ScreenPtr pScreen,
FBManagerFuncsPtr funcs
){
- if(xf86ManagerGeneration != serverGeneration) {
- if((xf86FBMangerIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- xf86ManagerGeneration = serverGeneration;
- }
-
- pScreen->devPrivates[xf86FBMangerIndex].ptr = (pointer)funcs;
+ xf86FBManagerKey = &xf86FBManagerKey;
+ dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
return TRUE;
}
@@ -65,9 +59,9 @@ _X_EXPORT Bool xf86RegisterOffscreenManager(
_X_EXPORT Bool
xf86FBManagerRunning(ScreenPtr pScreen)
{
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!pScreen->devPrivates[xf86FBMangerIndex].ptr)
+ if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
return FALSE;
return TRUE;
@@ -81,9 +75,10 @@ xf86RegisterFreeBoxCallback(
){
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv);
@@ -101,9 +96,10 @@ xf86AllocateOffscreenArea(
){
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return NULL;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return NULL;
return (*funcs->AllocateOffscreenArea)(
@@ -122,9 +118,10 @@ xf86AllocateOffscreenLinear(
){
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return NULL;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return NULL;
return (*funcs->AllocateOffscreenLinear)(
@@ -139,10 +136,10 @@ xf86FreeOffscreenArea(FBAreaPtr area)
if(!area) return;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return;
- if(!(funcs =
- (FBManagerFuncsPtr)area->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &area->pScreen->devPrivates, xf86FBManagerKey)))
return;
(*funcs->FreeOffscreenArea)(area);
@@ -158,10 +155,10 @@ xf86FreeOffscreenLinear(FBLinearPtr linear)
if(!linear) return;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return;
- if(!(funcs =
- (FBManagerFuncsPtr)linear->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &linear->pScreen->devPrivates, xf86FBManagerKey)))
return;
(*funcs->FreeOffscreenLinear)(linear);
@@ -179,10 +176,10 @@ xf86ResizeOffscreenArea(
if(!resize) return FALSE;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs =
- (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &resize->pScreen->devPrivates, xf86FBManagerKey)))
return FALSE;
return (*funcs->ResizeOffscreenArea)(resize, w, h);
@@ -197,10 +194,10 @@ xf86ResizeOffscreenLinear(
if(!resize) return FALSE;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs =
- (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &resize->pScreen->devPrivates, xf86FBManagerKey)))
return FALSE;
return (*funcs->ResizeOffscreenLinear)(resize, size);
@@ -220,9 +217,10 @@ xf86QueryLargestOffscreenArea(
*w = 0;
*h = 0;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->QueryLargestOffscreenArea)(
@@ -240,9 +238,10 @@ xf86QueryLargestOffscreenLinear(
*size = 0;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->QueryLargestOffscreenLinear)(
@@ -255,9 +254,10 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
{
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->PurgeOffscreenAreas)(pScreen);
@@ -269,8 +269,7 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
\************************************************************/
-static unsigned long xf86FBGeneration = 0;
-static int xf86FBScreenIndex = -1;
+static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKey;
typedef struct _FBLink {
FBArea area;
@@ -320,8 +319,8 @@ localRegisterFreeBoxCallback(
FreeBoxCallbackProcPtr *newCallbacks;
DevUnion *newPrivates;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
newCallbacks = xrealloc( offman->FreeBoxesUpdateCallback,
sizeof(FreeBoxCallbackProcPtr) * (offman->NumCallbacks + 1));
@@ -446,8 +445,8 @@ localAllocateOffscreenArea(
FBManagerPtr offman;
FBAreaPtr area = NULL;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData)))
SendCallFreeBoxCallbacks(offman);
@@ -464,8 +463,8 @@ localFreeOffscreenArea(FBAreaPtr area)
ScreenPtr pScreen;
pScreen = area->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->UsedAreas;
if(!pLink) return;
@@ -505,8 +504,8 @@ localResizeOffscreenArea(
FBLinkPtr pLink, newLink, pLinkPrev = NULL;
pScreen = resize->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
/* find this link */
if(!(pLink = offman->UsedAreas))
return FALSE;
@@ -625,8 +624,8 @@ localQueryLargestOffscreenArea(
if((preferences < 0) || (preferences > 3))
return FALSE;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
if(severity < 0) severity = 0;
if(severity > 2) severity = 2;
@@ -731,8 +730,8 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
RegionRec FreedRegion;
Bool anyUsed = FALSE;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->UsedAreas;
if(!pLink) return TRUE;
@@ -780,8 +779,8 @@ LinearRemoveCBWrapper(FBAreaPtr area)
FBLinearLinkPtr pLink, pLinkPrev = NULL;
ScreenPtr pScreen = area->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->LinearAreas;
if(!pLink) return;
@@ -911,7 +910,8 @@ localAllocateOffscreenLinear(
BoxPtr extents;
int w, h, pitch;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
/* Try to allocate from linear memory first...... */
#ifdef DEBUG
@@ -991,8 +991,8 @@ localFreeOffscreenLinear(FBLinearPtr linear)
FBLinearLinkPtr pLink, pLinkPrev = NULL;
ScreenPtr pScreen = linear->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->LinearAreas;
if(!pLink) return;
@@ -1049,8 +1049,8 @@ localResizeOffscreenLinear(FBLinearPtr resize, int length)
FBLinearLinkPtr pLink;
ScreenPtr pScreen = resize->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->LinearAreas;
if(!pLink) return FALSE;
@@ -1099,7 +1099,8 @@ localQueryLargestOffscreenLinear(
int priority
)
{
- FBManagerPtr offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
FBLinearLinkPtr pLink;
FBLinearLinkPtr pLinkRet;
@@ -1130,7 +1131,8 @@ localQueryLargestOffscreenLinear(
FBManagerPtr offman;
BoxPtr extents;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
if((extents->x2 - extents->x1) == w)
*size = w * h;
@@ -1162,9 +1164,8 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen)
{
FBLinkPtr pLink, tmp;
FBLinearLinkPtr pLinearLink, tmp2;
- FBManagerPtr offman =
- (FBManagerPtr) pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pScreen->CloseScreen = offman->CloseScreen;
@@ -1188,7 +1189,7 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen)
xfree(offman->FreeBoxesUpdateCallback);
xfree(offman->devPrivates);
xfree(offman);
- pScreen->devPrivates[xf86FBScreenIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, NULL);
return (*pScreen->CloseScreen) (i, pScreen);
}
@@ -1332,19 +1333,13 @@ xf86InitFBManagerRegion(
if(REGION_NIL(FullRegion))
return FALSE;
- if(xf86FBGeneration != serverGeneration) {
- if((xf86FBScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- xf86FBGeneration = serverGeneration;
- }
-
if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
return FALSE;
offman = xalloc(sizeof(FBManager));
if(!offman) return FALSE;
- pScreen->devPrivates[xf86FBScreenIndex].ptr = (pointer)offman;
+ dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman);
offman->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86FBCloseScreen;
@@ -1380,11 +1375,11 @@ xf86InitFBManagerLinear(
return FALSE;
/* we expect people to have called the Area setup first for pixmap cache */
- if (!pScreen->devPrivates[xf86FBScreenIndex].ptr)
+ if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey))
return FALSE;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
offman->LinearAreas = xalloc(sizeof(FBLinearLink));
if (!offman->LinearAreas)
return FALSE;
@@ -1424,13 +1419,14 @@ xf86AllocateLinearOffscreenArea (
BoxPtr extents;
int w, h;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return NULL;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return NULL;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
w = extents->x2 - extents->x1;
diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c
index af2cd4a4c..63d1cb31c 100644
--- a/hw/xfree86/common/xf86sbusBus.c
+++ b/hw/xfree86/common/xf86sbusBus.c
@@ -602,8 +602,7 @@ xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp)
pScrn->virtualY = psdp->height;
}
-static int sbusPaletteIndex = -1;
-static unsigned long sbusPaletteGeneration = 0;
+static DevPrivateKey sbusPaletteKey = &sbusPaletteKey;
typedef struct _sbusCmap {
sbusDevicePtr psdp;
CloseScreenProcPtr CloseScreen;
@@ -613,7 +612,8 @@ typedef struct _sbusCmap {
unsigned char origBlue[16];
} sbusCmapRec, *sbusCmapPtr;
-#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr)((pScreen)->devPrivates[sbusPaletteIndex].ptr))
+#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, sbusPaletteKey))
static void
xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
@@ -673,13 +673,8 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
struct fbcmap fbcmap;
unsigned char data[2];
- if(sbusPaletteGeneration != serverGeneration) {
- if((sbusPaletteIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- sbusPaletteGeneration = serverGeneration;
- }
cmap = xnfcalloc(1, sizeof(sbusCmapRec));
- pScreen->devPrivates[sbusPaletteIndex].ptr = cmap;
+ dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap);
cmap->psdp = psdp;
fbcmap.index = 0;
fbcmap.count = 16;
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index eac0d7e2c..7483e20d2 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -110,23 +110,22 @@ static void xf86XVAdjustFrame(int index, int x, int y, int flags);
static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
-static int XF86XVWindowIndex = -1;
-int XF86XvScreenIndex = -1;
-static unsigned long XF86XVGeneration = 0;
+static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKey;
+DevPrivateKey XF86XvScreenKey;
static unsigned long PortResource = 0;
-int (*XvGetScreenIndexProc)(void) = NULL;
+DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
unsigned long (*XvGetRTPortProc)(void) = NULL;
int (*XvScreenInitProc)(ScreenPtr) = NULL;
#define GET_XV_SCREEN(pScreen) \
- ((XvScreenPtr)((pScreen)->devPrivates[XF86XvScreenIndex].ptr))
+ ((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
#define GET_XF86XV_SCREEN(pScreen) \
- ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+ ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
#define GET_XF86XV_WINDOW(pWin) \
- ((XF86XVWindowPtr)((pWin)->devPrivates[XF86XVWindowIndex].ptr))
+ ((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey))
static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL;
static int NumGenDrivers = 0;
@@ -233,21 +232,12 @@ xf86XVScreenInit(
XvScreenPtr pxvs;
if(num <= 0 ||
- !XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc)
- return FALSE;
-
- if(XF86XVGeneration != serverGeneration) {
- if((XF86XVWindowIndex = AllocateWindowPrivateIndex()) < 0)
- return FALSE;
- XF86XVGeneration = serverGeneration;
- }
-
- if(!AllocateWindowPrivate(pScreen,XF86XVWindowIndex,0))
+ !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
return FALSE;
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
- XF86XvScreenIndex = (*XvGetScreenIndexProc)();
+ XF86XvScreenKey = (*XvGetScreenKeyProc)();
PortResource = (*XvGetRTPortProc)();
pxvs = GET_XV_SCREEN(pScreen);
@@ -977,7 +967,7 @@ xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
memset(winPriv, 0, sizeof(XF86XVWindowRec));
winPriv->PortRec = portPriv;
winPriv->next = PrivRoot;
- pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv);
}
portPriv->pDraw = (DrawablePtr)pWin;
@@ -998,8 +988,8 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
if(prevPriv)
prevPriv->next = winPriv->next;
else
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)winPriv->next;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ winPriv->next);
xfree(winPriv);
break;
}
@@ -1037,7 +1027,7 @@ xf86XVDestroyWindow(WindowPtr pWin)
xfree(tmp);
}
- pWin->devPrivates[XF86XVWindowIndex].ptr = NULL;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL);
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
ret = (*pScreen->DestroyWindow)(pWin);
@@ -1094,8 +1084,8 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
@@ -1146,8 +1136,8 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
@@ -1844,7 +1834,8 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
int status;
pval[0] = key;
pval[1] = IncludeInferiors;
- pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status);
+ pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status,
+ (XID)0, serverClient);
if(!pGC) return;
ValidateGC(pDraw, pGC);
if (pPriv) pPriv->pGC = pGC;
diff --git a/hw/xfree86/common/xf86xvmc.c b/hw/xfree86/common/xf86xvmc.c
index f8ff0bed4..05267a240 100644
--- a/hw/xfree86/common/xf86xvmc.c
+++ b/hw/xfree86/common/xf86xvmc.c
@@ -56,11 +56,10 @@ typedef struct {
XvMCAdaptorPtr dixinfo;
} xf86XvMCScreenRec, *xf86XvMCScreenPtr;
-static unsigned long XF86XvMCGeneration = 0;
-static int XF86XvMCScreenIndex = -1;
+static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKey;
-#define XF86XVMC_GET_PRIVATE(pScreen) \
- (xf86XvMCScreenPtr)((pScreen)->devPrivates[XF86XvMCScreenIndex].ptr)
+#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey)
static int
@@ -164,19 +163,12 @@ _X_EXPORT Bool xf86XvMCScreenInit(
{
XvMCAdaptorPtr pAdapt;
xf86XvMCScreenPtr pScreenPriv;
- XvScreenPtr pxvs =
- (XvScreenPtr)(pScreen->devPrivates[XF86XvScreenIndex].ptr);
-
+ XvScreenPtr pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ XF86XvScreenKey);
int i, j;
if(!XvMCScreenInitProc) return FALSE;
- if(XF86XvMCGeneration != serverGeneration) {
- if((XF86XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- XF86XvMCGeneration = serverGeneration;
- }
-
if(!(pAdapt = xalloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
return FALSE;
@@ -185,7 +177,7 @@ _X_EXPORT Bool xf86XvMCScreenInit(
return FALSE;
}
- pScreen->devPrivates[XF86XvMCScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, XF86XvMCScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86XvMCCloseScreen;
diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h
index e716c9c6a..4200dac80 100644
--- a/hw/xfree86/common/xf86xvpriv.h
+++ b/hw/xfree86/common/xf86xvpriv.h
@@ -30,10 +30,11 @@
#define _XF86XVPRIV_H_
#include "xf86xv.h"
+#include "privates.h"
/*** These are DDX layer privates ***/
-extern int XF86XvScreenIndex;
+extern DevPrivateKey XF86XvScreenKey;
typedef struct {
DestroyWindowProcPtr DestroyWindow;
diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h
index 41f060b2a..191b3ef89 100644
--- a/hw/xfree86/dixmods/extmod/modinit.h
+++ b/hw/xfree86/dixmods/extmod/modinit.h
@@ -129,8 +129,11 @@ extern void ShmRegisterFuncs(
extern void XaceExtensionInit(INITARGS);
#endif
+#ifdef XSELINUX
+extern void XSELinuxExtensionInit(INITARGS);
+#endif
+
#if 1
-extern void SecurityExtensionSetup(INITARGS);
extern void SecurityExtensionInit(INITARGS);
#endif
diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c
index fa9530860..295e05e9e 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -62,8 +62,7 @@ unsigned char DGAReqCode = 0;
int DGAErrorBase;
int DGAEventBase;
-static int DGAGeneration = 0;
-static int DGAClientPrivateIndex;
+static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKey;
static int DGACallbackRefCount = 0;
/* This holds the client's version information */
@@ -72,7 +71,11 @@ typedef struct {
int minor;
} DGAPrivRec, *DGAPrivPtr;
-#define DGAPRIV(c) ((c)->devPrivates[DGAClientPrivateIndex].ptr)
+#define DGA_GETPRIV(c) ((DGAPrivPtr) \
+ dixLookupPrivate(&(c)->devPrivates, DGAClientPrivateKey))
+#define DGA_SETPRIV(c,p) \
+ dixSetPrivate(&(c)->devPrivates, DGAClientPrivateKey, p)
+
void
XFree86DGAExtensionInit(INITARGS)
@@ -97,23 +100,6 @@ XFree86DGAExtensionInit(INITARGS)
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;
- }
}
@@ -590,12 +576,12 @@ ProcXDGASetClientVersion(ClientPtr client)
DGAPrivPtr pPriv;
REQUEST_SIZE_MATCH(xXDGASetClientVersionReq);
- if ((pPriv = DGAPRIV(client)) == NULL) {
+ if ((pPriv = DGA_GETPRIV(client)) == NULL) {
pPriv = xalloc(sizeof(DGAPrivRec));
/* XXX Need to look into freeing this */
if (!pPriv)
return BadAlloc;
- DGAPRIV(client) = pPriv;
+ DGA_SETPRIV(client, pPriv);
}
pPriv->major = stuff->major;
pPriv->minor = stuff->minor;
diff --git a/hw/xfree86/dixmods/extmod/xf86misc.c b/hw/xfree86/dixmods/extmod/xf86misc.c
index 3a6f83eca..66278a298 100644
--- a/hw/xfree86/dixmods/extmod/xf86misc.c
+++ b/hw/xfree86/dixmods/extmod/xf86misc.c
@@ -41,8 +41,7 @@
#endif
static int miscErrorBase;
-static int MiscGeneration = 0;
-static int MiscClientPrivateIndex;
+static DevPrivateKey MiscClientPrivateKey = &MiscClientPrivateKey;
/* This holds the client's version information */
typedef struct {
@@ -50,7 +49,10 @@ typedef struct {
int minor;
} MiscPrivRec, *MiscPrivPtr;
-#define MPRIV(c) ((c)->devPrivates[MiscClientPrivateIndex].ptr)
+#define M_GETPRIV(c) ((MiscPrivPtr) \
+ dixLookupPrivate(&(c)->devPrivates, MiscClientPrivateKey))
+#define M_SETPRIV(c,p) \
+ dixSetPrivate(&(c)->devPrivates, MiscClientPrivateKey, p)
static void XF86MiscResetProc(
ExtensionEntry* /* extEntry */
@@ -61,7 +63,7 @@ ClientVersion(ClientPtr client, int *major, int *minor)
{
MiscPrivPtr pPriv;
- pPriv = MPRIV(client);
+ pPriv = M_GETPRIV(client);
if (!pPriv) {
if (major) *major = 0;
if (minor) *minor = 0;
@@ -123,24 +125,6 @@ XFree86MiscExtensionInit(void)
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,
@@ -205,7 +189,9 @@ ProcXF86MiscSetSaver(client)
if (stuff->screen > screenInfo.numScreens)
return BadValue;
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
+ vptr = (ScrnInfoPtr)
+ dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates,
+ xf86ScreenKey);
REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq);
@@ -233,7 +219,9 @@ ProcXF86MiscGetSaver(client)
if (stuff->screen > screenInfo.numScreens)
return BadValue;
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
+ vptr = (ScrnInfoPtr)
+ dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates,
+ xf86ScreenKey);
REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq);
rep.type = X_Reply;
@@ -497,11 +485,11 @@ ProcXF86MiscSetClientVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq);
- if ((pPriv = MPRIV(client)) == NULL) {
+ if ((pPriv = M_GETPRIV(client)) == NULL) {
pPriv = xalloc(sizeof(MiscPrivRec));
if (!pPriv)
return BadAlloc;
- MPRIV(client) = pPriv;
+ M_SETPRIV(client, pPriv);
}
if (xf86GetVerbosity() > 1)
ErrorF("SetClientVersion: %i %i\n",stuff->major,stuff->minor);
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 3b054a829..718d40fbd 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -52,8 +52,7 @@ from Kaleb S. KEITHLEY
#define DEFAULT_XF86VIDMODE_VERBOSITY 3
static int VidModeErrorBase;
-static int VidModeGeneration = 0;
-static int VidModeClientPrivateIndex;
+static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKey;
/* This holds the client's version information */
typedef struct {
@@ -61,7 +60,10 @@ typedef struct {
int minor;
} VidModePrivRec, *VidModePrivPtr;
-#define VMPRIV(c) ((c)->devPrivates[VidModeClientPrivateIndex].ptr)
+#define VM_GETPRIV(c) ((VidModePrivPtr) \
+ dixLookupPrivate(&(c)->devPrivates, VidModeClientPrivateKey))
+#define VM_SETPRIV(c,p) \
+ dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey, p)
static void XF86VidModeResetProc(
ExtensionEntry* /* extEntry */
@@ -145,10 +147,12 @@ typedef struct _XF86VidModeScreenPrivate {
Bool hasWindow;
} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
-static int ScreenPrivateIndex;
+static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKey;
-#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr)
-#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v);
+#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
+ dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
+#define SetScreenPrivate(s,v) \
+ dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v)
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s)
#define New(t) (xalloc (sizeof (t)))
@@ -172,7 +176,6 @@ XFree86VidModeExtensionInit(void)
#ifdef XF86VIDMODE_EVENTS
EventType = CreateNewResourceType(XF86VidModeFreeEvents);
- ScreenPrivateIndex = AllocateScreenPrivateIndex ();
#endif
for(i = 0; i < screenInfo.numScreens; i++) {
@@ -187,27 +190,9 @@ XFree86VidModeExtensionInit(void)
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 &&
+ EventType &&
#endif
(extEntry = AddExtension(XF86VIDMODENAME,
XF86VidModeNumberEvents,
@@ -239,7 +224,7 @@ ClientMajorVersion(ClientPtr client)
{
VidModePrivPtr pPriv;
- pPriv = VMPRIV(client);
+ pPriv = VM_GETPRIV(client);
if (!pPriv)
return 0;
else
@@ -1682,11 +1667,11 @@ ProcXF86VidModeSetClientVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
- if ((pPriv = VMPRIV(client)) == NULL) {
+ if ((pPriv = VM_GETPRIV(client)) == NULL) {
pPriv = xalloc(sizeof(VidModePrivRec));
if (!pPriv)
return BadAlloc;
- VMPRIV(client) = pPriv;
+ VM_SETPRIV(client, pPriv);
}
pPriv->major = stuff->major;
pPriv->minor = stuff->minor;
diff --git a/hw/xfree86/dixmods/extmod/xvmod.c b/hw/xfree86/dixmods/extmod/xvmod.c
index 7c1450c7a..6b3f1149a 100644
--- a/hw/xfree86/dixmods/extmod/xvmod.c
+++ b/hw/xfree86/dixmods/extmod/xvmod.c
@@ -16,7 +16,7 @@ void
XvRegister()
{
XvScreenInitProc = XvScreenInit;
- XvGetScreenIndexProc = XvGetScreenIndex;
+ XvGetScreenKeyProc = XvGetScreenKey;
XvGetRTPortProc = XvGetRTPort;
XvMCScreenInitProc = XvMCScreenInit;
}
diff --git a/hw/xfree86/dixmods/extmod/xvmodproc.h b/hw/xfree86/dixmods/extmod/xvmodproc.h
index 81356a149..b39c915b4 100644
--- a/hw/xfree86/dixmods/extmod/xvmodproc.h
+++ b/hw/xfree86/dixmods/extmod/xvmodproc.h
@@ -5,7 +5,7 @@
#include "xvmcext.h"
-extern int (*XvGetScreenIndexProc)(void);
+extern DevPrivateKey (*XvGetScreenKeyProc)(void);
extern unsigned long (*XvGetRTPortProc)(void);
extern int (*XvScreenInitProc)(ScreenPtr);
extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr);
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 2408357e5..b736c6ae0 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -78,8 +78,8 @@ extern Bool noPanoramiXExtension;
#endif
static int DRIEntPrivIndex = -1;
-static int DRIScreenPrivIndex = -1;
-static int DRIWindowPrivIndex = -1;
+static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKey;
+static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKey;
static unsigned long DRIGeneration = 0;
static unsigned int DRIDrawableValidationStamp = 0;
@@ -342,20 +342,18 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
pDRIEntPriv = DRI_ENT_PRIV(pScrn);
- if (DRIGeneration != serverGeneration) {
- if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
+ DRIScreenPrivKey = &DRIScreenPrivKey;
+ if (DRIGeneration != serverGeneration)
DRIGeneration = serverGeneration;
- }
pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- DRIScreenPrivIndex = -1;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ DRIScreenPrivKey = NULL;
return FALSE;
}
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
pDRIPriv->drmFD = pDRIEntPriv->drmFD;
pDRIPriv->directRenderingSupport = TRUE;
pDRIPriv->pDriverInfo = pDRIInfo;
@@ -380,7 +378,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
&pDRIPriv->hSAREA) < 0)
{
pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
drmClose(pDRIPriv->drmFD);
DRIDrvMsg(pScreen->myNum, X_INFO,
"[drm] drmAddMap failed\n");
@@ -397,7 +395,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
(drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
{
pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
drmClose(pDRIPriv->drmFD);
DRIDrvMsg(pScreen->myNum, X_INFO,
"[drm] drmMap failed\n");
@@ -427,7 +425,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
&pDRIPriv->pDriverInfo->hFrameBuffer) < 0)
{
pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
drmClose(pDRIPriv->drmFD);
DRIDrvMsg(pScreen->myNum, X_INFO,
@@ -743,8 +741,8 @@ DRICloseScreen(ScreenPtr pScreen)
}
xfree(pDRIPriv);
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- DRIScreenPrivIndex = -1;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ DRIScreenPrivKey = NULL;
}
}
@@ -771,30 +769,13 @@ drmServerInfo DRIDRMServerInfo = {
Bool
DRIExtensionInit(void)
{
- int i;
- ScreenPtr pScreen;
-
- if (DRIScreenPrivIndex < 0 || DRIGeneration != serverGeneration) {
+ if (!DRIScreenPrivKey || DRIGeneration != serverGeneration) {
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;
@@ -1270,9 +1251,8 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList);
/* save private off of preallocated index */
- pWin->devPrivates[DRIWindowPrivIndex].ptr =
- (pointer)pDRIDrawablePriv;
-
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
+ pDRIDrawablePriv);
pDRIPriv->nrWindows++;
if (pDRIDrawablePriv->nrects)
@@ -1330,7 +1310,7 @@ DRIDrawablePrivDestroy(WindowPtr pWin)
drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable);
xfree(pDRIDrawablePriv);
- pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
}
static Bool
diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h
index c3b0aeede..ae970d834 100644
--- a/hw/xfree86/dri/dristruct.h
+++ b/hw/xfree86/dri/dristruct.h
@@ -37,15 +37,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#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)))
+#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey))
typedef struct _DRIDrawablePrivRec
{
@@ -65,13 +60,12 @@ struct _DRIContextPrivRec
void** pContextStore;
};
-#define DRI_SCREEN_PRIV(pScreen) \
- ((DRIScreenPrivIndex < 0) ? \
- NULL : \
- ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr)))
+#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey))
#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
- (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
+ dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
+ DRIScreenPrivKey))
#define DRI_ENT_PRIV(pScrn) \
((DRIEntPrivIndex < 0) ? \
diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c
index ceead8219..b8d306eb4 100644
--- a/hw/xfree86/exa/examodule.c
+++ b/hw/xfree86/exa/examodule.c
@@ -42,8 +42,7 @@ typedef struct _ExaXorgScreenPrivRec {
OptionInfoPtr options;
} ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr;
-static int exaXorgServerGeneration;
-static int exaXorgScreenPrivateIndex;
+static DevPrivateKey exaXorgScreenPrivateKey = &exaXorgScreenPrivateKey;
typedef enum {
EXAOPT_MIGRATION_HEURISTIC,
@@ -72,8 +71,8 @@ static Bool
exaXorgCloseScreen (int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
- ExaXorgScreenPrivPtr pScreenPriv =
- pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr;
+ ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
pScreen->CloseScreen = pScreenPriv->SavedCloseScreen;
@@ -89,8 +88,8 @@ static void
exaXorgEnableDisableFBAccess (int index, Bool enable)
{
ScreenPtr pScreen = screenInfo.screens[index];
- ExaXorgScreenPrivPtr pScreenPriv =
- pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr;
+ ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
if (!enable)
exaEnableDisableFBAccess (index, enable);
@@ -114,11 +113,6 @@ exaDDXDriverInit(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ExaXorgScreenPrivPtr pScreenPriv;
- if (exaXorgServerGeneration != serverGeneration) {
- exaXorgScreenPrivateIndex = AllocateScreenPrivateIndex();
- exaXorgServerGeneration = serverGeneration;
- }
-
pScreenPriv = xcalloc (1, sizeof(ExaXorgScreenPrivRec));
if (pScreenPriv == NULL)
return;
@@ -174,7 +168,7 @@ exaDDXDriverInit(ScreenPtr pScreen)
pExaScr->info->DownloadFromScreen = NULL;
}
- pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr = pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey, pScreenPriv);
pScreenPriv->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess;
pScrn->EnableDisableFBAccess = exaXorgEnableDisableFBAccess;
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index 5d06b05c7..49c7d271b 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -63,7 +63,9 @@
#include "globals.h"
#include "os.h"
#include "osdep.h"
+#include "privates.h"
#include "resource.h"
+#include "registry.h"
#include "servermd.h"
#include "scrnintstr.h"
#include "windowstr.h"
@@ -113,6 +115,16 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(QueryColors)
/* cursor.c */
SYMFUNC(FreeCursor)
+ /* deprecated.c */
+ SYMFUNC(LookupClient)
+ SYMFUNC(LookupDrawable)
+ SYMFUNC(LookupWindow)
+ SYMFUNC(SecurityLookupDrawable)
+ SYMFUNC(SecurityLookupWindow)
+ SYMFUNC(LookupIDByType)
+ SYMFUNC(LookupIDByClass)
+ SYMFUNC(SecurityLookupIDByClass)
+ SYMFUNC(SecurityLookupIDByType)
/* devices.c */
SYMFUNC(Ones)
SYMFUNC(InitButtonClassDeviceStruct)
@@ -128,8 +140,6 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(InitKeyboardDeviceStruct)
SYMFUNC(SendMappingNotify)
SYMFUNC(InitPointerDeviceStruct)
- SYMFUNC(LookupKeyboardDevice)
- SYMFUNC(LookupPointerDevice)
/* dispatch.c */
SYMFUNC(SetInputCheck)
SYMFUNC(SendErrorToClient)
@@ -159,13 +169,6 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(dixLookupWindow)
SYMFUNC(dixLookupClient)
SYMFUNC(dixLookupGC)
- /* following are deprecated */
- SYMFUNC(LookupClient)
- SYMFUNC(LookupDrawable)
- SYMFUNC(LookupWindow)
- SYMFUNC(SecurityLookupDrawable)
- SYMFUNC(SecurityLookupWindow)
- /* end deprecated */
SYMFUNC(NoopDDA)
SYMFUNC(QueueWorkProc)
SYMFUNC(RegisterBlockAndWakeupHandlers)
@@ -191,11 +194,11 @@ _X_HIDDEN void *dixLookupTab[] = {
#endif
/* property.c */
SYMFUNC(ChangeWindowProperty)
+ SYMFUNC(dixChangeWindowProperty)
/* extension.c */
SYMFUNC(AddExtension)
SYMFUNC(AddExtensionAlias)
SYMFUNC(CheckExtension)
- SYMFUNC(DeclareExtensionSecurity)
SYMFUNC(MinorOpcodeOfRequest)
SYMFUNC(StandardMinorOpcode)
#ifdef XEVIE
@@ -234,7 +237,7 @@ _X_HIDDEN void *dixLookupTab[] = {
#ifdef XV
/* XXX These are exported from the DDX, not DIX. */
SYMVAR(XvScreenInitProc)
- SYMVAR(XvGetScreenIndexProc)
+ SYMVAR(XvGetScreenKeyProc)
SYMVAR(XvGetRTPortProc)
SYMVAR(XvMCScreenInitProc)
#endif
@@ -259,42 +262,38 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(GetScratchPixmapHeader)
SYMFUNC(FreeScratchPixmapHeader)
/* privates.c */
- SYMFUNC(AllocateExtensionPrivate)
- SYMFUNC(AllocateExtensionPrivateIndex)
- SYMFUNC(AllocateClientPrivate)
- SYMFUNC(AllocateClientPrivateIndex)
- SYMFUNC(AllocateGCPrivate)
- SYMFUNC(AllocateGCPrivateIndex)
- SYMFUNC(AllocateWindowPrivate)
- SYMFUNC(AllocateWindowPrivateIndex)
- SYMFUNC(AllocateScreenPrivateIndex)
- SYMFUNC(AllocateColormapPrivateIndex)
- SYMFUNC(AllocateDevicePrivateIndex)
- SYMFUNC(AllocateDevicePrivate)
- SYMFUNC(AllocatePixmapPrivateIndex)
- SYMFUNC(AllocatePixmapPrivate)
+ SYMFUNC(dixRequestPrivate)
+ SYMFUNC(dixRegisterPrivateInitFunc)
+ SYMFUNC(dixRegisterPrivateDeleteFunc)
+ SYMFUNC(dixAllocatePrivate)
+ SYMFUNC(dixFreePrivates)
+ SYMFUNC(dixRegisterPrivateOffset)
+ SYMFUNC(dixLookupPrivateOffset)
/* resource.c */
SYMFUNC(AddResource)
SYMFUNC(ChangeResourceValue)
SYMFUNC(CreateNewResourceClass)
SYMFUNC(CreateNewResourceType)
+ SYMFUNC(dixLookupResource)
SYMFUNC(FakeClientID)
SYMFUNC(FreeResource)
SYMFUNC(FreeResourceByType)
SYMFUNC(GetXIDList)
SYMFUNC(GetXIDRange)
- SYMFUNC(LookupIDByType)
- SYMFUNC(LookupIDByClass)
SYMFUNC(LegalNewID)
- SYMFUNC(SecurityLookupIDByClass)
- SYMFUNC(SecurityLookupIDByType)
SYMFUNC(FindClientResourcesByType)
SYMFUNC(FindAllClientResources)
SYMVAR(lastResourceType)
SYMVAR(TypeMask)
-#ifdef RES
+ SYMVAR(ResourceStateCallback)
+ /* registry.c */
+#ifdef XREGISTRY
SYMFUNC(RegisterResourceName)
- SYMVAR(ResourceNames)
+ SYMFUNC(LookupMajorName)
+ SYMFUNC(LookupRequestName)
+ SYMFUNC(LookupEventName)
+ SYMFUNC(LookupErrorName)
+ SYMFUNC(LookupResourceName)
#endif
/* swaprep.c */
SYMFUNC(CopySwap32Write)
@@ -322,6 +321,7 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(NotClippedByChildren)
SYMFUNC(ResizeChildrenWinSize)
SYMFUNC(SaveScreens)
+ SYMFUNC(dixSaveScreens)
SYMFUNC(SendVisibilityNotify)
SYMFUNC(SetWinSize)
SYMFUNC(SetBorderSize)
@@ -512,7 +512,7 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(PictureTransformPoint3d)
SYMFUNC(PictureGetSubpixelOrder)
SYMFUNC(PictureSetSubpixelOrder)
- SYMVAR(PictureScreenPrivateIndex)
+ SYMVAR(PictureScreenPrivateKey)
/* mipict.c */
SYMFUNC(miPictureInit)
SYMFUNC(miComputeCompositeRegion)
diff --git a/hw/xfree86/loader/misym.c b/hw/xfree86/loader/misym.c
index 025983b09..aa712c03a 100644
--- a/hw/xfree86/loader/misym.c
+++ b/hw/xfree86/loader/misym.c
@@ -200,9 +200,9 @@ _X_HIDDEN void *miLookupTab[] = {
SYMFUNC(miOverlaySetRootClip)
SYMVAR(miEmptyBox)
SYMVAR(miEmptyData)
- SYMVAR(miZeroLineScreenIndex)
+ SYMVAR(miZeroLineScreenKey)
SYMVAR(miSpritePointerFuncs)
- SYMVAR(miPointerScreenIndex)
+ SYMVAR(miPointerScreenKey)
SYMVAR(miInstalledMaps)
SYMVAR(miInitVisualsProc)
#ifdef DAMAGE
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 050b873fb..623e87ab5 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -906,8 +906,8 @@ _X_HIDDEN void *xfree86LookupTab[] = {
#endif
/* General variables (from xf86.h) */
- SYMVAR(xf86ScreenIndex)
- SYMVAR(xf86PixmapIndex)
+ SYMVAR(xf86ScreenKey)
+ SYMVAR(xf86PixmapKey)
SYMVAR(xf86Screens)
SYMVAR(byte_reversed)
SYMVAR(xf86inSuspend)
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index b5101642b..acf34c1d1 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -226,7 +226,8 @@ xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg)
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
CursorPtr cursor = xf86_config->cursor;
int c;
- CARD8 *bits = cursor ? cursor->devPriv[screen->myNum] : NULL;
+ CARD8 *bits = cursor ? dixLookupPrivate(&cursor->devPrivates,
+ screen) : NULL;
/* Save ARGB versions of these colors */
xf86_config->cursor_fg = (CARD32) fg | 0xff000000;
@@ -612,7 +613,7 @@ xf86_reload_cursors (ScreenPtr screen)
else
#endif
(*cursor_info->LoadCursorImage)(cursor_info->pScrn,
- cursor->devPriv[screen->myNum]);
+ dixLookupPrivate(&cursor->devPrivates, screen));
(*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y);
(*cursor_info->ShowCursor)(cursor_info->pScrn);
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index bb7f94581..e2668fbbc 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -59,11 +59,11 @@ static Bool xf86RandR12Init12 (ScreenPtr pScreen);
static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen);
#endif
-static int xf86RandR12Index = -1;
-static int xf86RandR12Generation;
+static int xf86RandR12Generation;
+static DevPrivateKey xf86RandR12Key;
-#define XF86RANDRINFO(p) \
- ((XF86RandRInfoPtr)(p)->devPrivates[xf86RandR12Index].ptr)
+#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
+ dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key))
static int
xf86RandR12ModeRefresh (DisplayModePtr mode)
@@ -340,7 +340,7 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen,
PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
Bool ret = FALSE;
- if (xf86RandR12Index != -1) {
+ if (xf86RandR12Key) {
if (randrp->virtualX == -1 || randrp->virtualY == -1)
{
randrp->virtualX = pScrn->virtualX;
@@ -368,7 +368,7 @@ finish:
if (pRoot && pScrn->vtSema)
(*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
#if RANDR_12_INTERFACE
- if ((xf86RandR12Index != -1) && WindowTable[pScreen->myNum] && ret)
+ if (xf86RandR12Key && WindowTable[pScreen->myNum] && ret)
RRScreenSizeNotify (pScreen);
#endif
return ret;
@@ -468,7 +468,7 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen)
mmHeight);
}
- if (xf86RandR12Index == -1)
+ if (xf86RandR12Key == NULL)
return TRUE;
if (randrp->virtualX == -1 || randrp->virtualY == -1)
@@ -496,11 +496,11 @@ xf86RandR12Init (ScreenPtr pScreen)
if (!noPanoramiXExtension)
return TRUE;
#endif
+
if (xf86RandR12Generation != serverGeneration)
- {
- xf86RandR12Index = AllocateScreenPrivateIndex();
xf86RandR12Generation = serverGeneration;
- }
+
+ xf86RandR12Key = &xf86RandR12Key;
randrp = xalloc (sizeof (XF86RandRInfoRec));
if (!randrp)
@@ -526,7 +526,7 @@ xf86RandR12Init (ScreenPtr pScreen)
randrp->maxX = randrp->maxY = 0;
- pScreen->devPrivates[xf86RandR12Index].ptr = randrp;
+ dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp);
#if RANDR_12_INTERFACE
if (!xf86RandR12Init12 (pScreen))
@@ -545,7 +545,7 @@ xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations)
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
#endif
- if (xf86RandR12Index == -1)
+ if (xf86RandR12Key == NULL)
return;
randrp = XF86RANDRINFO(pScreen);
@@ -1076,7 +1076,7 @@ xf86RandR12CreateScreenResources12 (ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- if (xf86RandR12Index == -1)
+ if (xf86RandR12Key == NULL)
return TRUE;
for (c = 0; c < config->num_crtc; c++)
@@ -1099,7 +1099,7 @@ xf86RandR12TellChanged (ScreenPtr pScreen)
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
int c;
- if (xf86RandR12Index == -1)
+ if (xf86RandR12Key == NULL)
return;
xf86RandR12SetInfo12 (pScreen);
diff --git a/hw/xfree86/os-support/solaris/sun_mouse.c b/hw/xfree86/os-support/solaris/sun_mouse.c
index aa509d08b..b1b7797f1 100644
--- a/hw/xfree86/os-support/solaris/sun_mouse.c
+++ b/hw/xfree86/os-support/solaris/sun_mouse.c
@@ -121,8 +121,11 @@ static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse);
static void vuidMouseAdjustFrame(int index, int x, int y, int flags);
static int vuidMouseGeneration = 0;
-static int vuidMouseScreenIndex;
-#define vuidMouseScreenPrivate(s) ((s)->devPrivates[vuidMouseScreenIndex].ptr)
+static DevPrivateKey vuidMouseScreenKey = &vuidMouseScreenKey;
+#define vuidGetMouseScreenPrivate(s) ((VuidMsePtr) \
+ dixLookupPrivate(&(s)->devPrivates, vuidMouseScreenKey))
+#define vuidSetMouseScreenPrivate(s,p) \
+ dixSetPrivate(&(s)->devPrivates, vuidMouseScreenKey, p)
#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
static inline
@@ -455,7 +458,7 @@ static void vuidMouseAdjustFrame(int index, int x, int y, int flags)
ScrnInfoPtr pScrn = xf86Screens[index];
ScreenPtr pScreen = pScrn->pScreen;
xf86AdjustFrameProc *wrappedAdjustFrame
- = (xf86AdjustFrameProc *) vuidMouseScreenPrivate(pScreen);
+ = (xf86AdjustFrameProc *) vuidMouseGetScreenPrivate(pScreen);
VuidMsePtr m;
if(wrappedAdjustFrame) {
@@ -496,15 +499,12 @@ vuidMouseProc(DeviceIntPtr pPointer, int what)
case DEVICE_INIT:
#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
if (vuidMouseGeneration != serverGeneration) {
- if ((vuidMouseScreenIndex = AllocateScreenPrivateIndex()) >= 0) {
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
- vuidMouseScreenPrivate(pScreen)
- = (pointer) pScrn->AdjustFrame;
+ vuidMouseSetScreenPrivate(pScreen, pScrn->AdjustFrame);
pScrn->AdjustFrame = vuidMouseAdjustFrame;
}
- }
vuidMouseGeneration = serverGeneration;
}
#endif
diff --git a/hw/xfree86/rac/xf86RAC.c b/hw/xfree86/rac/xf86RAC.c
index 0d41599b1..8985f38b0 100644
--- a/hw/xfree86/rac/xf86RAC.c
+++ b/hw/xfree86/rac/xf86RAC.c
@@ -39,9 +39,8 @@
pScreen->x = y;}
#define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x
-#define SCREEN_PROLOG(x) \
- pScreen->x = \
- ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->x
+#define SCREEN_PROLOG(x) pScreen->x = ((RACScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->x
#define SCREEN_EPILOG(x,y) pScreen->x = y;
#define WRAP_PICT_COND(x,y,cond) if (ps)\
@@ -50,9 +49,8 @@
ps->x = y;}
#define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;}
-#define PICTURE_PROLOGUE(field) \
- ps->field = \
- ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->field
+#define PICTURE_PROLOGUE(field) ps->field = \
+ ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->field
#define PICTURE_EPILOGUE(field, wrap) \
ps->field = wrap
@@ -65,9 +63,9 @@
#define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x
#define SPRITE_PROLOG miPointerScreenPtr PointPriv = \
-(miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;\
- RACScreenPtr pScreenPriv = \
-((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr);\
+ (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); \
+ RACScreenPtr pScreenPriv = \
+ ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey));\
PointPriv->spriteFuncs = pScreenPriv->miSprite;
#define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\
PointPriv->spriteFuncs = &RACSpriteFuncs;
@@ -82,7 +80,7 @@
(x)->ops = &RACGCOps;\
(x)->funcs = &RACGCFuncs;
#define GC_UNWRAP(x)\
- RACGCPtr pGCPriv = (RACGCPtr) (x)->devPrivates[RACGCIndex].ptr;\
+ RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&(x)->devPrivates, RACGCKey);\
(x)->ops = pGCPriv->wrapOps;\
(x)->funcs = pGCPriv->wrapFuncs;
@@ -252,9 +250,8 @@ static miPointerSpriteFuncRec RACSpriteFuncs = {
RACSpriteMoveCursor
};
-static int RACScreenIndex = -1;
-static int RACGCIndex = -1;
-static unsigned long RACGeneration = 0;
+static DevPrivateKey RACScreenKey = &RACScreenKey;
+static DevPrivateKey RACGCKey = &RACGCKey;
Bool
@@ -268,24 +265,17 @@ xf86RACInit(ScreenPtr pScreen, unsigned int flag)
#endif
pScrn = xf86Screens[pScreen->myNum];
- PointPriv = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;
-
+ PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miPointerScreenKey);
DPRINT_S("RACInit",pScreen->myNum);
- if (RACGeneration != serverGeneration) {
- if ( ((RACScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((RACGCIndex = AllocateGCPrivateIndex()) < 0))
- return FALSE;
-
- RACGeneration = serverGeneration;
- }
- if (!AllocateGCPrivate(pScreen, RACGCIndex, sizeof(RACGCRec)))
+ if (!dixRequestPrivate(RACGCKey, sizeof(RACGCRec)))
return FALSE;
if (!(pScreenPriv = xalloc(sizeof(RACScreenRec))))
return FALSE;
- pScreen->devPrivates[RACScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, RACScreenKey, pScreenPriv);
WRAP_SCREEN(CloseScreen, RACCloseScreen);
WRAP_SCREEN(SaveScreen, RACSaveScreen);
@@ -322,10 +312,10 @@ static Bool
RACCloseScreen (int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
- miPointerScreenPtr PointPriv
- = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
+ miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, miPointerScreenKey);
#ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
@@ -581,8 +571,8 @@ static void
RACAdjustFrame(int index, int x, int y, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACAdjustFrame",index);
xf86EnableAccess(xf86Screens[index]);
@@ -594,8 +584,8 @@ static Bool
RACSwitchMode(int index, DisplayModePtr mode, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACSwitchMode",index);
xf86EnableAccess(xf86Screens[index]);
@@ -607,8 +597,8 @@ static Bool
RACEnterVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACEnterVT",index);
xf86EnableAccess(xf86Screens[index]);
@@ -620,8 +610,8 @@ static void
RACLeaveVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACLeaveVT",index);
xf86EnableAccess(xf86Screens[index]);
@@ -633,8 +623,8 @@ static void
RACFreeScreen(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACFreeScreen",index);
xf86EnableAccess(xf86Screens[index]);
@@ -646,7 +636,7 @@ static Bool
RACCreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
- RACGCPtr pGCPriv = (RACGCPtr) (pGC)->devPrivates[RACGCIndex].ptr;
+ RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&pGC->devPrivates, RACGCKey);
Bool ret;
DPRINT_S("RACCreateGC",pScreen->myNum);
diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index 457807698..5b1ce5e1f 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -8,8 +8,7 @@
#include "colormapst.h"
#include "cursorstr.h"
-int xf86CursorScreenIndex = -1;
-static unsigned long xf86CursorGeneration = 0;
+DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKey;
/* sprite functions */
@@ -48,12 +47,6 @@ xf86InitCursor(
xf86CursorScreenPtr ScreenPriv;
miPointerScreenPtr PointPriv;
- if (xf86CursorGeneration != serverGeneration) {
- if ((xf86CursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- xf86CursorGeneration = serverGeneration;
- }
-
if (!xf86InitHardwareCursor(pScreen, infoPtr))
return FALSE;
@@ -61,7 +54,7 @@ xf86InitCursor(
if (!ScreenPriv)
return FALSE;
- pScreen->devPrivates[xf86CursorScreenIndex].ptr = ScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv);
ScreenPriv->SWCursor = TRUE;
ScreenPriv->isUp = FALSE;
@@ -84,7 +77,7 @@ xf86InitCursor(
ScreenPriv->PalettedCursor = TRUE;
}
- PointPriv = pScreen->devPrivates[miPointerScreenIndex].ptr;
+ PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
ScreenPriv->showTransparent = PointPriv->showTransparent;
if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT)
@@ -113,10 +106,10 @@ static Bool
xf86CursorCloseScreen(int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- miPointerScreenPtr PointPriv =
- pScreen->devPrivates[miPointerScreenIndex].ptr;
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, miPointerScreenKey);
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (ScreenPriv->isUp && pScrn->vtSema)
xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
@@ -146,8 +139,8 @@ xf86CursorQueryBestSize(
unsigned short *height,
ScreenPtr pScreen)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (class == CursorShape) {
if(*width > ScreenPriv->CursorInfoPtr->MaxWidth)
@@ -161,8 +154,8 @@ xf86CursorQueryBestSize(
static void
xf86CursorInstallColormap(ColormapPtr pMap)
{
- xf86CursorScreenPtr ScreenPriv =
- pMap->pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pMap->pScreen->devPrivates, xf86CursorScreenKey);
ScreenPriv->pInstalledMap = pMap;
@@ -175,8 +168,8 @@ xf86CursorRecolorCursor(
CursorPtr pCurs,
Bool displayed)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (!displayed)
return;
@@ -195,8 +188,8 @@ xf86CursorEnableDisableFBAccess(
Bool enable)
{
ScreenPtr pScreen = screenInfo.screens[index];
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (!enable && ScreenPriv->CurrentCursor != NullCursor) {
CursorPtr currentCursor = ScreenPriv->CurrentCursor;
@@ -226,10 +219,10 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags)
{
Bool ret;
ScreenPtr pScreen = screenInfo.screens[index];
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
- miPointerScreenPtr PointPriv =
- pScreen->devPrivates[miPointerScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+ miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, miPointerScreenKey);
if (ScreenPriv->isUp) {
xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
@@ -254,11 +247,11 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags)
static Bool
xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (pCurs->refcnt <= 1)
- pCurs->devPriv[pScreen->myNum] = NULL;
+ dixSetPrivate(&pCurs->devPrivates, pScreen, NULL);
return (*ScreenPriv->spriteFuncs->RealizeCursor)(pScreen, pCurs);
}
@@ -266,12 +259,12 @@ xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
static Bool
xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (pCurs->refcnt <= 1) {
- xfree(pCurs->devPriv[pScreen->myNum]);
- pCurs->devPriv[pScreen->myNum] = NULL;
+ xfree(dixLookupPrivate(&pCurs->devPrivates, pScreen));
+ dixSetPrivate(&pCurs->devPrivates, pScreen, NULL);
}
return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCurs);
@@ -280,8 +273,8 @@ xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
static void
xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
miPointerScreenPtr PointPriv;
@@ -306,8 +299,8 @@ xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
ScreenPriv->HotX = pCurs->bits->xhot;
ScreenPriv->HotY = pCurs->bits->yhot;
- PointPriv = pScreen->devPrivates[miPointerScreenIndex].ptr;
-
+ PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miPointerScreenKey);
if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || ((
#ifdef ARGB_CURSOR
pCurs->bits->argb && infoPtr->UseHWCursorARGB &&
@@ -351,8 +344,8 @@ xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
static void
xf86CursorMoveCursor(ScreenPtr pScreen, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
ScreenPriv->x = x;
ScreenPriv->y = y;
@@ -369,8 +362,8 @@ xf86CursorMoveCursor(ScreenPtr pScreen, int x, int y)
void
xf86ForceHWCursor (ScreenPtr pScreen, Bool on)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (on)
{
diff --git a/hw/xfree86/ramdac/xf86CursorPriv.h b/hw/xfree86/ramdac/xf86CursorPriv.h
index 472e2b06b..f82be2edc 100644
--- a/hw/xfree86/ramdac/xf86CursorPriv.h
+++ b/hw/xfree86/ramdac/xf86CursorPriv.h
@@ -45,6 +45,6 @@ Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr);
CARD32 xf86ReverseBitOrder(CARD32 data);
-extern int xf86CursorScreenIndex;
+extern DevPrivateKey xf86CursorScreenKey;
#endif /* _XF86CURSORPRIV_H */
diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c
index 91caea047..d10e283d7 100644
--- a/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/hw/xfree86/ramdac/xf86HWCurs.c
@@ -113,8 +113,8 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
void
xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
unsigned char *bits;
@@ -123,7 +123,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
return;
}
- bits = pCurs->devPriv[pScreen->myNum];
+ bits = (unsigned char *)dixLookupPrivate(&pCurs->devPrivates, pScreen);
x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX;
y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY;
@@ -133,7 +133,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
#endif
if (!bits) {
bits = (*infoPtr->RealizeCursor)(infoPtr, pCurs);
- pCurs->devPriv[pScreen->myNum] = bits;
+ dixSetPrivate(&pCurs->devPrivates, pScreen, bits);
}
if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
@@ -157,8 +157,8 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
void
xf86SetTransparentCursor(ScreenPtr pScreen)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
if (!ScreenPriv->transparentData)
@@ -178,8 +178,8 @@ xf86SetTransparentCursor(ScreenPtr pScreen)
void
xf86MoveCursor(ScreenPtr pScreen, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX;
@@ -191,8 +191,8 @@ xf86MoveCursor(ScreenPtr pScreen, int x, int y)
void
xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
#ifdef ARGB_CURSOR
diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
index 52fdcbef6..74beefb67 100644
--- a/hw/xfree86/shadowfb/shadow.c
+++ b/hw/xfree86/shadowfb/shadow.c
@@ -94,14 +94,13 @@ typedef struct {
} ShadowGCRec, *ShadowGCPtr;
-static int ShadowScreenIndex = -1;
-static int ShadowGCIndex = -1;
-static unsigned long ShadowGeneration = 0;
+static DevPrivateKey ShadowScreenKey = &ShadowScreenKey;
+static DevPrivateKey ShadowGCKey = &ShadowGCKey;
#define GET_SCREEN_PRIVATE(pScreen) \
- (ShadowScreenPtr)((pScreen)->devPrivates[ShadowScreenIndex].ptr)
+ (ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey)
#define GET_GC_PRIVATE(pGC) \
- (ShadowGCPtr)((pGC)->devPrivates[ShadowGCIndex].ptr)
+ (ShadowGCPtr)dixLookupPrivate(&(pGC)->devPrivates, ShadowGCKey);
#define SHADOW_GC_FUNC_PROLOGUE(pGC)\
ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\
@@ -172,20 +171,13 @@ ShadowFBInit2 (
if(!preRefreshArea && !postRefreshArea) return FALSE;
- if (ShadowGeneration != serverGeneration) {
- if(((ShadowScreenIndex = AllocateScreenPrivateIndex ()) < 0) ||
- ((ShadowGCIndex = AllocateGCPrivateIndex()) < 0))
- return FALSE;
- ShadowGeneration = serverGeneration;
- }
-
- if(!AllocateGCPrivate(pScreen, ShadowGCIndex, sizeof(ShadowGCRec)))
+ if(!dixRequestPrivate(ShadowGCKey, sizeof(ShadowGCRec)))
return FALSE;
if(!(pPriv = (ShadowScreenPtr)xalloc(sizeof(ShadowScreenRec))))
return FALSE;
- pScreen->devPrivates[ShadowScreenIndex].ptr = (pointer)pPriv;
+ dixSetPrivate(&pScreen->devPrivates, ShadowScreenKey, pPriv);
pPriv->pScrn = pScrn;
pPriv->preRefresh = preRefreshArea;
diff --git a/hw/xfree86/xaa/xaaDashLine.c b/hw/xfree86/xaa/xaaDashLine.c
index 1a4732baa..63233e05d 100644
--- a/hw/xfree86/xaa/xaaDashLine.c
+++ b/hw/xfree86/xaa/xaaDashLine.c
@@ -35,7 +35,8 @@ XAAPolyLinesDashed(
#endif
){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip);
int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip);
unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
diff --git a/hw/xfree86/xaa/xaaGC.c b/hw/xfree86/xaa/xaaGC.c
index b3dc83ada..e6083d529 100644
--- a/hw/xfree86/xaa/xaaGC.c
+++ b/hw/xfree86/xaa/xaaGC.c
@@ -38,7 +38,8 @@ Bool
XAACreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
- XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
Bool ret;
XAA_SCREEN_PROLOGUE(pScreen,CreateGC);
diff --git a/hw/xfree86/xaa/xaaGCmisc.c b/hw/xfree86/xaa/xaaGCmisc.c
index a7a3f4081..5823cc064 100644
--- a/hw/xfree86/xaa/xaaGCmisc.c
+++ b/hw/xfree86/xaa/xaaGCmisc.c
@@ -305,7 +305,8 @@ XAAValidatePolylines(
DrawablePtr pDraw )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
if(pGC->lineStyle == LineSolid) changes &= ~GCDashList;
if(!changes) return;
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 196569278..892cbcfc3 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -39,22 +39,20 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet);
static void XAAEnableDisableFBAccess (int index, Bool enable);
static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
-static int XAAScreenIndex = -1;
-static int XAAGCIndex = -1;
-static int XAAPixmapIndex = -1;
+static DevPrivateKey XAAScreenKey = &XAAScreenKey;
+static DevPrivateKey XAAGCKey = &XAAGCKey;
+static DevPrivateKey XAAPixmapKey = &XAAPixmapKey;
-static unsigned long XAAGeneration = 0;
-
-int XAAGetScreenIndex(void) {
- return XAAScreenIndex;
+DevPrivateKey XAAGetScreenKey(void) {
+ return XAAScreenKey;
}
-int XAAGetGCIndex(void) {
- return XAAGCIndex;
+DevPrivateKey XAAGetGCKey(void) {
+ return XAAGCKey;
}
-int XAAGetPixmapIndex(void) {
- return XAAPixmapIndex;
+DevPrivateKey XAAGetPixmapKey(void) {
+ return XAAPixmapKey;
}
/* temp kludge */
@@ -104,25 +102,16 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
if (!infoRec)
return TRUE;
- if (XAAGeneration != serverGeneration) {
- if ( ((XAAScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((XAAGCIndex = AllocateGCPrivateIndex()) < 0) ||
- ((XAAPixmapIndex = AllocatePixmapPrivateIndex()) < 0))
- return FALSE;
-
- XAAGeneration = serverGeneration;
- }
-
- if (!AllocateGCPrivate(pScreen, XAAGCIndex, sizeof(XAAGCRec)))
+ if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec)))
return FALSE;
- if (!AllocatePixmapPrivate(pScreen, XAAPixmapIndex, sizeof(XAAPixmapRec)))
+ if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec)))
return FALSE;
if (!(pScreenPriv = xalloc(sizeof(XAAScreenRec))))
return FALSE;
- pScreen->devPrivates[XAAScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, XAAScreenKey, pScreenPriv);
if(!xf86FBManagerRunning(pScreen))
infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS);
@@ -219,7 +208,7 @@ XAACloseScreen (int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
pScrn->EnterVT = pScreenPriv->EnterVT;
pScrn->LeaveVT = pScreenPriv->LeaveVT;
@@ -516,7 +505,7 @@ XAAEnterVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
return((*pScreenPriv->EnterVT)(index, flags));
}
@@ -526,7 +515,7 @@ XAALeaveVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec;
if(infoRec->NeedToSync) {
@@ -549,7 +538,7 @@ XAASetDGAMode(int index, int num, DGADevicePtr devRet)
ScreenPtr pScreen = screenInfo.screens[index];
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
int ret;
if (!num && infoRec->dgaSaves) { /* restore old pixmap cache state */
@@ -611,7 +600,7 @@ XAAEnableDisableFBAccess (int index, Bool enable)
ScreenPtr pScreen = screenInfo.screens[index];
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
if(!enable) {
if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps))
diff --git a/hw/xfree86/xaa/xaaLineMisc.c b/hw/xfree86/xaa/xaaLineMisc.c
index 537b08b97..cefb59a8e 100644
--- a/hw/xfree86/xaa/xaaLineMisc.c
+++ b/hw/xfree86/xaa/xaaLineMisc.c
@@ -64,7 +64,8 @@ void
XAAComputeDash(GCPtr pGC)
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
Bool EvenDash = (pGC->numInDashList & 0x01) ? FALSE : TRUE;
int PatternLength = 0;
unsigned char* DashPtr = (unsigned char*)pGC->dash;
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index 47599d7d3..64ca998ee 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -151,11 +151,10 @@ typedef struct {
int (*TiledFillChooser)(GCPtr);
} XAAOverlayRec, *XAAOverlayPtr;
-static int XAAOverlayIndex = -1;
-static unsigned long XAAOverlayGeneration = 0;
+static DevPrivateKey XAAOverlayKey = &XAAOverlayKey;
#define GET_OVERLAY_PRIV(pScreen) \
- ((XAAOverlayPtr)((pScreen)->devPrivates[XAAOverlayIndex].ptr))
+ (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey)
#define SWITCH_DEPTH(d) \
if(pOverPriv->currentDepth != d) { \
@@ -173,18 +172,10 @@ XAAInitDualFramebufferOverlay(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAOverlayPtr pOverPriv;
- if (XAAOverlayGeneration != serverGeneration) {
- if((XAAOverlayIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
-
- XAAOverlayGeneration = serverGeneration;
- }
-
-
if(!(pOverPriv = xalloc(sizeof(XAAOverlayRec))))
return FALSE;
- pScreen->devPrivates[XAAOverlayIndex].ptr = (pointer)pOverPriv;
+ dixSetPrivate(&pScreen->devPrivates, XAAOverlayKey, pOverPriv);
pOverPriv->pScrn = pScrn;
pOverPriv->callback = callback;
diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c
index 02c556b33..443bda628 100644
--- a/hw/xfree86/xaa/xaaStateChange.c
+++ b/hw/xfree86/xaa/xaaStateChange.c
@@ -274,18 +274,17 @@ typedef struct _XAAStateWrapRec {
#endif
} XAAStateWrapRec, *XAAStateWrapPtr;
-static int XAAStateIndex = -1;
-static unsigned long XAAStateGeneration = 0;
+static DevPrivateKey XAAStateKey = &XAAStateKey;
/* Wrap functions start here */
#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\
-(XAAStateWrapPtr)(pGC->pScreen->devPrivates[XAAStateIndex].ptr)
+(XAAStateWrapPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAStateKey)
#define GET_STATEPRIV_SCREEN(pScreen) XAAStateWrapPtr pStatePriv =\
-(XAAStateWrapPtr)(pScreen->devPrivates[XAAStateIndex].ptr)
+(XAAStateWrapPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAStateKey)
#define GET_STATEPRIV_PSCRN(pScrn) XAAStateWrapPtr pStatePriv =\
-(XAAStateWrapPtr)(pScrn->pScreen->devPrivates[XAAStateIndex].ptr)
+(XAAStateWrapPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAStateKey)
#define STATE_CHECK_SP(pStatePriv) {\
ScrnInfoPtr pScrn = pStatePriv->pScrn;\
@@ -1504,12 +1503,8 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
XAAStateWrapPtr pStatePriv;
int i = 0;
- if (XAAStateGeneration != serverGeneration) {
- if((XAAStateIndex = AllocateScreenPrivateIndex()) < 0) return FALSE;
- XAAStateGeneration = serverGeneration;
- }
if(!(pStatePriv = xalloc(sizeof(XAAStateWrapRec)))) return FALSE;
- pScreen->devPrivates[XAAStateIndex].ptr = (pointer)pStatePriv;
+ dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv);
pStatePriv->RestoreAccelState = infoRec->RestoreAccelState;
pStatePriv->pScrn = pScrn;
diff --git a/hw/xfree86/xaa/xaaWrapper.c b/hw/xfree86/xaa/xaaWrapper.c
index b0176f03f..5d6ea05cf 100644
--- a/hw/xfree86/xaa/xaaWrapper.c
+++ b/hw/xfree86/xaa/xaaWrapper.c
@@ -86,10 +86,8 @@ typedef struct {
int depth;
} xaaWrapperScrPrivRec, *xaaWrapperScrPrivPtr;
-#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr)( \
- (xaaWrapperScrPrivateIndex != -1) \
- ? (s)->devPrivates[xaaWrapperScrPrivateIndex].ptr\
- : NULL))
+#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr) \
+ dixLookupPrivate(&(s)->devPrivates, xaaWrapperScrPrivateKey))
#define xaaWrapperScrPriv(s) xaaWrapperScrPrivPtr pScrPriv = xaaWrapperGetScrPriv(s)
#define wrap(priv,real,mem,func) {\
@@ -127,13 +125,12 @@ typedef struct _xaaWrapperGCPriv {
} xaaWrapperGCPrivRec, *xaaWrapperGCPrivPtr;
#define xaaWrapperGetGCPriv(pGC) ((xaaWrapperGCPrivPtr) \
- (pGC)->devPrivates[xaaWrapperGCPrivateIndex].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, xaaWrapperGCPrivateKey))
#define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC)
-static int xaaWrapperScrPrivateIndex = -1;
-static int xaaWrapperGCPrivateIndex = -1;
-static int xaaWrapperGeneration = -1;
+static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKey;
+static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKey;
static Bool
xaaWrapperCreateScreenResources(ScreenPtr pScreen)
@@ -274,18 +271,8 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
#ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- if (xaaWrapperGeneration != serverGeneration) {
- xaaWrapperScrPrivateIndex = AllocateScreenPrivateIndex ();
- if (xaaWrapperScrPrivateIndex == -1)
- return FALSE;
- xaaWrapperGCPrivateIndex = AllocateGCPrivateIndex ();
- if (xaaWrapperGCPrivateIndex == -1)
- return FALSE;
- xaaWrapperGeneration = serverGeneration;
- }
- if (!AllocateGCPrivate (pScreen, xaaWrapperGCPrivateIndex,
- sizeof (xaaWrapperGCPrivRec)))
+ if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec)))
return FALSE;
pScrPriv = (xaaWrapperScrPrivPtr) xalloc (sizeof (xaaWrapperScrPrivRec));
@@ -335,7 +322,7 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
}
#endif
pScrPriv->depth = depth;
- pScreen->devPrivates[xaaWrapperScrPrivateIndex].ptr = (pointer) pScrPriv;
+ dixSetPrivate(&pScreen->devPrivates, xaaWrapperScrPrivateKey, pScrPriv);
*func = XAASync;
@@ -486,8 +473,8 @@ xaaWrapperGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
void
XAASync(ScreenPtr pScreen)
{
- XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAGetScreenIndex()].ptr;
+ XAAScreenPtr pScreenPriv = (XAAScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, XAAGetScreenKey());
XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec;
if(infoRec->NeedToSync) {
diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h
index 686cc876d..e25b9df52 100644
--- a/hw/xfree86/xaa/xaalocal.h
+++ b/hw/xfree86/xaa/xaalocal.h
@@ -1629,9 +1629,9 @@ XAAGetPixelFromRGBA (
extern GCOps XAAFallbackOps;
extern GCOps *XAAGetFallbackOps(void);
extern GCFuncs XAAGCFuncs;
-extern int XAAGetScreenIndex(void);
-extern int XAAGetGCIndex(void);
-extern int XAAGetPixmapIndex(void);
+extern DevPrivateKey XAAGetScreenKey(void);
+extern DevPrivateKey XAAGetGCKey(void);
+extern DevPrivateKey XAAGetPixmapKey(void);
extern unsigned int XAAShiftMasks[32];
@@ -1640,28 +1640,28 @@ extern unsigned int byte_expand3[256], byte_reversed_expand3[256];
CARD32 XAAReverseBitOrder(CARD32 data);
#define GET_XAASCREENPTR_FROM_SCREEN(pScreen)\
- (pScreen)->devPrivates[XAAGetScreenIndex()].ptr
+ dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey())
#define GET_XAASCREENPTR_FROM_GC(pGC)\
- (pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr
+ dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey())
#define GET_XAASCREENPTR_FROM_DRAWABLE(pDraw)\
- (pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr
+ dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey())
#define GET_XAAINFORECPTR_FROM_SCREEN(pScreen)\
- ((XAAScreenPtr)((pScreen)->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec
+((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->AccelInfoRec
#define GET_XAAINFORECPTR_FROM_GC(pGC)\
-((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec
+((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
#define GET_XAAINFORECPTR_FROM_DRAWABLE(pDraw)\
-((XAAScreenPtr)((pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec
+((XAAScreenPtr)dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
#define GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn)\
-((XAAScreenPtr)((pScrn)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec
+((XAAScreenPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
#define XAA_GET_PIXMAP_PRIVATE(pix)\
- (XAAPixmapPtr)((pix)->devPrivates[XAAGetPixmapIndex()].ptr)
+ (XAAPixmapPtr)dixLookupPrivate(&(pix)->devPrivates, XAAGetPixmapKey())
#define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff))
diff --git a/hw/xfree86/xaa/xaawrap.h b/hw/xfree86/xaa/xaawrap.h
index 32c17a60c..38c97d70b 100644
--- a/hw/xfree86/xaa/xaawrap.h
+++ b/hw/xfree86/xaa/xaawrap.h
@@ -1,14 +1,14 @@
#define XAA_SCREEN_PROLOGUE(pScreen, field)\
((pScreen)->field = \
- ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field)
+ ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
#define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
#define XAA_GC_FUNC_PROLOGUE(pGC)\
- XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
(pGC)->funcs = pGCPriv->wrapFuncs;\
if(pGCPriv->flags)\
(pGC)->ops = pGCPriv->wrapOps
@@ -24,13 +24,13 @@
#define XAA_GC_OP_PROLOGUE(pGC)\
- XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
GCFuncs *oldFuncs = pGC->funcs;\
pGC->funcs = pGCPriv->wrapFuncs;\
pGC->ops = pGCPriv->wrapOps
#define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\
- XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
GCFuncs *oldFuncs = pGC->funcs;\
if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \
pGC->funcs = pGCPriv->wrapFuncs;\
@@ -44,7 +44,7 @@
#define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\
- XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\
GCFuncs *oldFuncs = pGC->funcs;\
pGC->funcs = pGCPriv->wrapFuncs;\
@@ -64,7 +64,7 @@
#ifdef RENDER
#define XAA_RENDER_PROLOGUE(pScreen,field)\
(GetPictureScreen(pScreen)->field = \
- ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field)
+ ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\
(GetPictureScreen(pScreen)->field = wrapper)
@@ -74,7 +74,7 @@
#define SYNC_CHECK(pGC) {\
XAAInfoRecPtr infoRec =\
-((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec;\
+((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \
if(infoRec->NeedToSync) {\
(*infoRec->Sync)(infoRec->pScrn);\
infoRec->NeedToSync = FALSE;\
diff --git a/hw/xfree86/xf4bpp/mfbfillarc.c b/hw/xfree86/xf4bpp/mfbfillarc.c
index d5b5372f5..89aeadd2b 100644
--- a/hw/xfree86/xf4bpp/mfbfillarc.c
+++ b/hw/xfree86/xf4bpp/mfbfillarc.c
@@ -253,7 +253,8 @@ xf4bppPolyFillArcSolid
mfbPrivGC *priv;
int rop;
- priv = (mfbPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr;
+ priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
rop = priv->rop;
if ((rop == RROP_NOP) || !(pGC->planemask & 1))
#else
diff --git a/hw/xfree86/xf4bpp/mfbimggblt.c b/hw/xfree86/xf4bpp/mfbimggblt.c
index 73e7ce064..4f9561161 100644
--- a/hw/xfree86/xf4bpp/mfbimggblt.c
+++ b/hw/xfree86/xf4bpp/mfbimggblt.c
@@ -149,7 +149,8 @@ xf4bppImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
- pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr;
+ pPrivGC = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
oldfillStyle = pPrivGC->colorRrop.fillStyle; /* GJA */
oldfg = pPrivGC->colorRrop.fgPixel; /* GJA */
oldalu = pPrivGC->colorRrop.alu; /* GJA */
diff --git a/hw/xfree86/xf4bpp/mfbzerarc.c b/hw/xfree86/xf4bpp/mfbzerarc.c
index c7a8c4d56..61fc7b184 100644
--- a/hw/xfree86/xf4bpp/mfbzerarc.c
+++ b/hw/xfree86/xf4bpp/mfbzerarc.c
@@ -108,7 +108,8 @@ v16ZeroArcSS
int pmask;
register int *paddr;
- if (((mfbPrivGC *)(pGC->devPrivates[mfbGetGCPrivateIndex()].ptr))->rop ==
+ if (((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop ==
RROP_BLACK)
pixel = 0;
else
diff --git a/hw/xfree86/xf4bpp/ppcArea.c b/hw/xfree86/xf4bpp/ppcArea.c
index e95696260..df7856a35 100644
--- a/hw/xfree86/xf4bpp/ppcArea.c
+++ b/hw/xfree86/xf4bpp/ppcArea.c
@@ -49,7 +49,7 @@ int alu ;
unsigned long int fg, bg, pm ;
int xSrc, ySrc ;
PixmapPtr pPixmap ;
-ppcPrivGC *pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr;
+ppcPrivGC *pPrivGC = dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey());
TRACE( ( "xf4bppFillArea(0x%x,%d,0x%x,0x%x)\n", pWin, nboxes, pBox, pGC ) ) ;
diff --git a/hw/xfree86/xf4bpp/ppcGC.c b/hw/xfree86/xf4bpp/ppcGC.c
index 674a38b78..7ef312d39 100644
--- a/hw/xfree86/xf4bpp/ppcGC.c
+++ b/hw/xfree86/xf4bpp/ppcGC.c
@@ -182,7 +182,7 @@ register GCPtr pGC ;
* a pointer to a ppcPrivGC in its slot.
*/
*pPriv = vgaPrototypeGCPriv;
- (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) = (pointer) pPriv;
+ dixSetPrivate(&pGC->devPrivates, mfbGetGCPrivateKey(), pPriv);
/* Set the vgaGCOps */
*pOps = vgaGCOps;
@@ -202,7 +202,7 @@ xf4bppDestroyGC( pGC )
if ( pGC->freeCompClip && pGC->pCompositeClip )
REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
if(pGC->ops->devPrivate.val) xfree( pGC->ops );
- xfree( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ;
+ xfree(dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()));
return ;
}
@@ -213,7 +213,7 @@ ppcChangePixmapGC
register Mask changes
)
{
-register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ;
+register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey());
register unsigned long int idx ; /* used for stepping through bitfields */
#define LOWBIT( x ) ( x & - x ) /* Two's complement */
@@ -291,8 +291,8 @@ xf4bppValidateGC( pGC, changes, pDrawable )
register ppcPrivGCPtr devPriv ;
WindowPtr pWin ;
- devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ;
-
+ devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
if ( pDrawable->type != devPriv->lastDrawableType ) {
devPriv->lastDrawableType = pDrawable->type ;
xf4bppChangeGCtype( pGC, devPriv ) ;
diff --git a/hw/xfree86/xf4bpp/ppcPixFS.c b/hw/xfree86/xf4bpp/ppcPixFS.c
index dfc648660..9fd29efce 100644
--- a/hw/xfree86/xf4bpp/ppcPixFS.c
+++ b/hw/xfree86/xf4bpp/ppcPixFS.c
@@ -124,7 +124,7 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()))->colorRrop.alu ) == GXnoop )
return ;
n = nInit * miFindMaxBand(pGC->pCompositeClip) ;
@@ -142,8 +142,8 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit,
ppt, pwidth, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
for ( ; n-- ; ppt++, pwidth++ ) {
@@ -258,14 +258,14 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
pTile = pGC->stipple ;
tlwidth = pTile->devKind ;
@@ -356,15 +356,15 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
- bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
+ bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
pTile = pGC->stipple ;
@@ -459,14 +459,14 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
/* the following code is for 8 bits per pixel addressable memory only */
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
pTile = pGC->tile.pixmap ;
tileWidth = pTile->drawable.width ;
diff --git a/hw/xfree86/xf4bpp/ppcPixmap.c b/hw/xfree86/xf4bpp/ppcPixmap.c
index 73524c3fc..d04aacf82 100644
--- a/hw/xfree86/xf4bpp/ppcPixmap.c
+++ b/hw/xfree86/xf4bpp/ppcPixmap.c
@@ -139,6 +139,7 @@ xf4bppCopyPixmap(pSrc)
pDst = xalloc(sizeof(PixmapRec) + size);
if (!pDst)
return NullPixmap;
+ pDst->devPrivates = NULL;
pDst->drawable = pSrc->drawable;
pDst->drawable.id = 0;
pDst->drawable.serialNumber = NEXT_SERIAL_NUMBER;
diff --git a/hw/xfree86/xf4bpp/ppcPolyPnt.c b/hw/xfree86/xf4bpp/ppcPolyPnt.c
index 1d6905563..c61fd6d26 100644
--- a/hw/xfree86/xf4bpp/ppcPolyPnt.c
+++ b/hw/xfree86/xf4bpp/ppcPolyPnt.c
@@ -102,7 +102,7 @@ if ( pDrawable->type == DRAWABLE_PIXMAP ) {
return ;
}
-devPriv = (ppcPrivGC *) ( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ;
+devPriv = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey());
if ( ( alu = devPriv->colorRrop.alu ) == GXnoop )
return ;
diff --git a/hw/xfree86/xf4bpp/ppcWinFS.c b/hw/xfree86/xf4bpp/ppcWinFS.c
index 78001d793..1522afd9e 100644
--- a/hw/xfree86/xf4bpp/ppcWinFS.c
+++ b/hw/xfree86/xf4bpp/ppcWinFS.c
@@ -96,7 +96,7 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
n = nInit * miFindMaxBand( pGC->pCompositeClip ) ;
@@ -114,8 +114,8 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit,
ppt, pwidth, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
for ( ; n-- ; ppt++, pwidth++ )
if ( *pwidth )
@@ -163,14 +163,14 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
xSrc = pGC->patOrg.x + pDrawable->x ;
ySrc = pGC->patOrg.y + pDrawable->y ;
@@ -215,15 +215,15 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
- bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
+ bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ;
xSrc = pGC->patOrg.x + pDrawable->x ;
ySrc = pGC->patOrg.y + pDrawable->y ;
@@ -260,7 +260,7 @@ int fSorted ;
TRACE( ( "xf4bppTileWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
@@ -268,7 +268,7 @@ int fSorted ;
xSrc = pGC->patOrg.x + pDrawable->x ;
ySrc = pGC->patOrg.y + pDrawable->y ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
for ( ; n-- ; ppt++, pwidth++ )
xf4bppTileRect( (WindowPtr)pDrawable, pGC->tile.pixmap, alu, pm,
diff --git a/hw/xfree86/xf4bpp/vgaGC.c b/hw/xfree86/xf4bpp/vgaGC.c
index 5a8604090..6495e5638 100644
--- a/hw/xfree86/xf4bpp/vgaGC.c
+++ b/hw/xfree86/xf4bpp/vgaGC.c
@@ -107,7 +107,7 @@ xf4bppChangeWindowGC( pGC, changes )
register GC *pGC ;
register Mask changes ;
{
-register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) ;
+register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey());
register unsigned long int idx ; /* used for stepping through bitfields */
#define LOWBIT( x ) ( x & - x ) /* Two's complement */
diff --git a/hw/xfree86/xf8_32bpp/cfb8_32.h b/hw/xfree86/xf8_32bpp/cfb8_32.h
index e14096568..6e985da20 100644
--- a/hw/xfree86/xf8_32bpp/cfb8_32.h
+++ b/hw/xfree86/xf8_32bpp/cfb8_32.h
@@ -22,10 +22,8 @@ typedef struct {
} cfb8_32ScreenRec, *cfb8_32ScreenPtr;
-extern int cfb8_32GCPrivateIndex; /* XXX */
-extern int cfb8_32GetGCPrivateIndex(void);
-extern int cfb8_32ScreenPrivateIndex; /* XXX */
-extern int cfb8_32GetScreenPrivateIndex(void);
+extern DevPrivateKey cfb8_32GetGCPrivateKey(void);
+extern DevPrivateKey cfb8_32GetScreenPrivateKey(void);
RegionPtr
cfb8_32CopyArea(
@@ -182,11 +180,11 @@ cfb8_32ChangeWindowAttributes(
);
-#define CFB8_32_GET_GC_PRIVATE(pGC)\
- (cfb8_32GCPtr)((pGC)->devPrivates[cfb8_32GetGCPrivateIndex()].ptr)
+#define CFB8_32_GET_GC_PRIVATE(pGC) ((cfb8_32GCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, cfb8_32GetGCPrivateKey()))
-#define CFB8_32_GET_SCREEN_PRIVATE(pScreen)\
- (cfb8_32ScreenPtr)((pScreen)->devPrivates[cfb8_32GetScreenPrivateIndex()].ptr)
+#define CFB8_32_GET_SCREEN_PRIVATE(pScreen) ((cfb8_32ScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, cfb8_32GetScreenPrivateKey()))
Bool xf86Overlay8Plus32Init (ScreenPtr pScreen);
diff --git a/hw/xfree86/xf8_32bpp/cfbscrinit.c b/hw/xfree86/xf8_32bpp/cfbscrinit.c
index 5e2657f2b..c3432b803 100644
--- a/hw/xfree86/xf8_32bpp/cfbscrinit.c
+++ b/hw/xfree86/xf8_32bpp/cfbscrinit.c
@@ -31,38 +31,37 @@
/* CAUTION: We require that cfb8 and cfb32 were NOT
compiled with CFB_NEED_SCREEN_PRIVATE */
-int cfb8_32GCPrivateIndex;
-int cfb8_32GetGCPrivateIndex(void) { return cfb8_32GCPrivateIndex; }
-int cfb8_32ScreenPrivateIndex;
-int cfb8_32GetScreenPrivateIndex(void) { return cfb8_32ScreenPrivateIndex; }
-static unsigned long cfb8_32Generation = 0;
+static DevPrivateKey cfb8_32GCPrivateKey = &cfb8_32GCPrivateKey;
+DevPrivateKey cfb8_32GetGCPrivateKey(void)
+{
+ return cfb8_32GCPrivateKey;
+}
+
+static DevPrivateKey cfb8_32ScreenPrivateKey = &cfb8_32ScreenPrivateKey;
+DevPrivateKey cfb8_32GetScreenPrivateKey(void)
+{
+ return cfb8_32ScreenPrivateKey;
+}
static Bool
cfb8_32AllocatePrivates(ScreenPtr pScreen)
{
cfb8_32ScreenPtr pScreenPriv;
- if(cfb8_32Generation != serverGeneration) {
- if(((cfb8_32GCPrivateIndex = AllocateGCPrivateIndex()) < 0) ||
- ((cfb8_32ScreenPrivateIndex = AllocateScreenPrivateIndex()) < 0))
- return FALSE;
- cfb8_32Generation = serverGeneration;
- }
-
if (!(pScreenPriv = xalloc(sizeof(cfb8_32ScreenRec))))
return FALSE;
- pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, pScreenPriv);
/* All cfb will have the same GC and Window private indicies */
- if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex))
+ if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateKey))
return FALSE;
- if(!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
+ if(!dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC)))
return FALSE;
- if(!AllocateGCPrivate(pScreen, cfb8_32GCPrivateIndex, sizeof(cfb8_32GCRec)))
+ if(!dixRequestPrivate(cfb8_32GCPrivateKey, sizeof(cfb8_32GCRec)))
return FALSE;
return TRUE;
@@ -160,7 +159,7 @@ cfb8_32CloseScreen (int i, ScreenPtr pScreen)
xfree(pScreenPriv->visualData);
xfree((pointer) pScreenPriv);
- pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, NULL);
return(cfb32CloseScreen(i, pScreen));
}
diff --git a/hw/xfree86/xf8_32bpp/xf86overlay.c b/hw/xfree86/xf8_32bpp/xf86overlay.c
index 47b2b52db..c63b3cfd1 100644
--- a/hw/xfree86/xf8_32bpp/xf86overlay.c
+++ b/hw/xfree86/xf8_32bpp/xf86overlay.c
@@ -177,23 +177,22 @@ typedef struct {
} OverlayPixmapRec, *OverlayPixmapPtr;
-static int OverlayScreenIndex = -1;
-static int OverlayGCIndex = -1;
-static int OverlayPixmapIndex = -1;
-static unsigned long OverlayGeneration = 0;
+static DevPrivateKey OverlayScreenKey = &OverlayScreenKey;
+static DevPrivateKey OverlayGCKey = &OverlayGCKey;
+static DevPrivateKey OverlayPixmapKey = &OverlayPixmapKey;
/** Macros **/
#define TILE_EXISTS(pGC) (!(pGC)->tileIsPixel && (pGC)->tile.pixmap)
-#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) \
- (OverlayPixmapPtr)((pPix)->devPrivates[OverlayPixmapIndex].ptr)
+#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) ((OverlayPixmapPtr) \
+ dixLookupPrivate(&(pPix)->devPrivates, OverlayPixmapKey))
-#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) \
- (OverlayScreenPtr)((pScreen)->devPrivates[OverlayScreenIndex].ptr)
+#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) ((OverlayScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, OverlayScreenKey))
-#define OVERLAY_GET_GC_PRIVATE(pGC) \
- (OverlayGCPtr)((pGC)->devPrivates[OverlayGCIndex].ptr)
+#define OVERLAY_GET_GC_PRIVATE(pGC) ((OverlayGCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, OverlayGCKey))
#define OVERLAY_GC_FUNC_PROLOGUE(pGC)\
OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\
@@ -255,26 +254,16 @@ xf86Overlay8Plus32Init (ScreenPtr pScreen)
{
OverlayScreenPtr pScreenPriv;
- if(OverlayGeneration != serverGeneration) {
- if(((OverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((OverlayGCIndex = AllocateGCPrivateIndex()) < 0) ||
- ((OverlayPixmapIndex = AllocatePixmapPrivateIndex()) < 0))
- return FALSE;
-
- OverlayGeneration = serverGeneration;
- }
-
- if (!AllocateGCPrivate(pScreen, OverlayGCIndex, sizeof(OverlayGCRec)))
+ if (!dixRequestPrivate(OverlayGCKey, sizeof(OverlayGCRec)))
return FALSE;
- if (!AllocatePixmapPrivate(pScreen, OverlayPixmapIndex,
- sizeof(OverlayPixmapRec)))
+ if (!dixRequestPrivate(OverlayPixmapKey, sizeof(OverlayPixmapRec)))
return FALSE;
if (!(pScreenPriv = xalloc(sizeof(OverlayScreenRec))))
return FALSE;
- pScreen->devPrivates[OverlayScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, OverlayScreenKey, pScreenPriv);
pScreenPriv->CreateGC = pScreen->CreateGC;
pScreenPriv->CloseScreen = pScreen->CloseScreen;
diff --git a/hw/xgl/egl/kinput.c b/hw/xgl/egl/kinput.c
index 981cffcfa..774e00eb5 100644
--- a/hw/xgl/egl/kinput.c
+++ b/hw/xgl/egl/kinput.c
@@ -439,7 +439,7 @@ KdKeybdProc(DeviceIntPtr pDevice, int onoff)
switch (onoff)
{
case DEVICE_INIT:
- if (pDev != LookupKeyboardDevice())
+ if (pDev != (DevicePtr)inputInfo.keyboard)
{
return !Success;
}
diff --git a/hw/xgl/egl/xegl.c b/hw/xgl/egl/xegl.c
index c671dbe7c..1cf615bb6 100644
--- a/hw/xgl/egl/xegl.c
+++ b/hw/xgl/egl/xegl.c
@@ -42,14 +42,13 @@
#define XEGL_DEFAULT_SCREEN_WIDTH 800
#define XEGL_DEFAULT_SCREEN_HEIGHT 600
-int xeglScreenGeneration = -1;
-int xeglScreenPrivateIndex;
+DevPrivateKey xeglScreenPrivateKey = &xeglScreenPrivateKey;
-#define XEGL_GET_SCREEN_PRIV(pScreen) \
- ((xeglScreenPtr) (pScreen)->devPrivates[xeglScreenPrivateIndex].ptr)
+#define XEGL_GET_SCREEN_PRIV(pScreen) ((xeglScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey))
-#define XEGL_SET_SCREEN_PRIV(pScreen, v) \
- ((pScreen)->devPrivates[xeglScreenPrivateIndex].ptr = (pointer) v)
+#define XEGL_SET_SCREEN_PRIV(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey, v)
#define XEGL_SCREEN_PRIV(pScreen) \
xeglScreenPtr pScreenPriv = XEGL_GET_SCREEN_PRIV (pScreen)
@@ -66,15 +65,6 @@ xeglAllocatePrivates (ScreenPtr pScreen)
{
xeglScreenPtr pScreenPriv;
- if (xeglScreenGeneration != serverGeneration)
- {
- xeglScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (xeglScreenPrivateIndex < 0)
- return FALSE;
-
- xeglScreenGeneration = serverGeneration;
- }
-
pScreenPriv = xalloc (sizeof (xeglScreenRec));
if (!pScreenPriv)
return FALSE;
diff --git a/hw/xgl/egl/xegl.h b/hw/xgl/egl/xegl.h
index be9b48c9c..0a07397bf 100644
--- a/hw/xgl/egl/xegl.h
+++ b/hw/xgl/egl/xegl.h
@@ -109,7 +109,7 @@ extern KdMouseInfo *kdMouseInfo;
extern KdOsFuncs *kdOsFuncs;
extern Bool kdDontZap;
extern Bool kdDisableZaphod;
-extern int xeglScreenPrivateIndex;
+extern DevPrivateKey xeglScreenPrivateKey;
extern KdMouseFuncs LinuxEvdevMouseFuncs;
extern KdKeyboardFuncs LinuxEvdevKeyboardFuncs;
@@ -117,8 +117,8 @@ extern KdKeyboardFuncs LinuxEvdevKeyboardFuncs;
(RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270)
#define RR_Reflect_All (RR_Reflect_X | RR_Reflect_Y)
-#define KdGetScreenPriv(pScreen) \
- ((xeglScreenPtr) ((pScreen)->devPrivates[xeglScreenPrivateIndex].ptr))
+#define KdGetScreenPriv(pScreen) ((xeglScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey))
#define KdScreenPriv(pScreen) \
xeglScreenPtr pScreenPriv = KdGetScreenPriv (pScreen)
diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c
index 87d8a4ea8..33b276b74 100644
--- a/hw/xgl/glx/xglx.c
+++ b/hw/xgl/glx/xglx.c
@@ -105,14 +105,13 @@ typedef struct _xglxScreen {
CloseScreenProcPtr CloseScreen;
} xglxScreenRec, *xglxScreenPtr;
-int xglxScreenGeneration = -1;
-int xglxScreenPrivateIndex;
+DevPrivateKey xglxScreenPrivateKey = &xglxScreenPrivateKey;
-#define XGLX_GET_SCREEN_PRIV(pScreen) \
- ((xglxScreenPtr) (pScreen)->devPrivates[xglxScreenPrivateIndex].ptr)
+#define XGLX_GET_SCREEN_PRIV(pScreen) ((xglxScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xglxScreenPrivateKey))
-#define XGLX_SET_SCREEN_PRIV(pScreen, v) \
- ((pScreen)->devPrivates[xglxScreenPrivateIndex].ptr = (pointer) v)
+#define XGLX_SET_SCREEN_PRIV(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, xglxScreenPrivateKey, v)
#define XGLX_SCREEN_PRIV(pScreen) \
xglxScreenPtr pScreenPriv = XGLX_GET_SCREEN_PRIV (pScreen)
@@ -122,10 +121,10 @@ typedef struct _xglxCursor {
} xglxCursorRec, *xglxCursorPtr;
#define XGLX_GET_CURSOR_PRIV(pCursor, pScreen) \
- ((xglxCursorPtr) (pCursor)->devPriv[(pScreen)->myNum])
+ ((xglxCursorPtr)dixLookupPrivate(&(pCursor)->devPrivates, pScreen))
#define XGLX_SET_CURSOR_PRIV(pCursor, pScreen, v) \
- ((pCursor)->devPriv[(pScreen)->myNum] = (pointer) v)
+ dixSetPrivate(&(pCursor)->devPrivates, pScreen, v)
#define XGLX_CURSOR_PRIV(pCursor, pScreen) \
xglxCursorPtr pCursorPriv = XGLX_GET_CURSOR_PRIV (pCursor, pScreen)
@@ -148,15 +147,6 @@ xglxAllocatePrivates (ScreenPtr pScreen)
{
xglxScreenPtr pScreenPriv;
- if (xglxScreenGeneration != serverGeneration)
- {
- xglxScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (xglxScreenPrivateIndex < 0)
- return FALSE;
-
- xglxScreenGeneration = serverGeneration;
- }
-
pScreenPriv = xalloc (sizeof (xglxScreenRec));
if (!pScreenPriv)
return FALSE;
@@ -1110,7 +1100,7 @@ xglxKeybdProc (DeviceIntPtr pDevice,
int xkbOp, xkbEvent, xkbError, xkbMajor, xkbMinor;
#endif
- if (pDev != LookupKeyboardDevice ())
+ if (pDev != (DevicePtr)inputInfo.keyboard)
return !Success;
xmodMap = XGetModifierMapping (xdisplay);
diff --git a/hw/xgl/xgl.h b/hw/xgl/xgl.h
index 80fa69577..03dc90c70 100644
--- a/hw/xgl/xgl.h
+++ b/hw/xgl/xgl.h
@@ -224,10 +224,11 @@ typedef struct _xglGlyph {
xglAreaPtr pArea;
} xglGlyphRec, *xglGlyphPtr;
-extern int xglGlyphPrivateIndex;
+extern DevPrivateKey xglGlyphPrivateKey;
#define XGL_GET_GLYPH_PRIV(pScreen, pGlyph) ((xglGlyphPtr) \
- (GetGlyphPrivatesForScreen (pGlyph, pScreen))[xglGlyphPrivateIndex].ptr)
+ dixLookupPrivate(GetGlyphPrivatesForScreen (pGlyph, pScreen), \
+ xglGlyphPrivateKey))
#define XGL_GLYPH_PRIV(pScreen, pGlyph) \
xglGlyphPtr pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pGlyph)
@@ -293,13 +294,13 @@ typedef struct _xglScreen {
#endif
} xglScreenRec, *xglScreenPtr;
-extern int xglScreenPrivateIndex;
+extern DevPrivateKey xglScreenPrivateKey;
-#define XGL_GET_SCREEN_PRIV(pScreen) \
- ((xglScreenPtr) (pScreen)->devPrivates[xglScreenPrivateIndex].ptr)
+#define XGL_GET_SCREEN_PRIV(pScreen) ((xglScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xglScreenPrivateKey))
-#define XGL_SET_SCREEN_PRIV(pScreen, v) \
- ((pScreen)->devPrivates[xglScreenPrivateIndex].ptr = (pointer) v)
+#define XGL_SET_SCREEN_PRIV(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, xglScreenPrivateKey, v)
#define XGL_SCREEN_PRIV(pScreen) \
xglScreenPtr pScreenPriv = XGL_GET_SCREEN_PRIV (pScreen)
@@ -334,10 +335,10 @@ typedef struct _xglGC {
GCOpsPtr ops;
} xglGCRec, *xglGCPtr;
-extern int xglGCPrivateIndex;
+extern DevPrivateKey xglGCPrivateKey;
-#define XGL_GET_GC_PRIV(pGC) \
- ((xglGCPtr) (pGC)->devPrivates[xglGCPrivateIndex].ptr)
+#define XGL_GET_GC_PRIV(pGC) ((xglGCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, xglGCPrivateKey))
#define XGL_GC_PRIV(pGC) \
xglGCPtr pGCPriv = XGL_GET_GC_PRIV (pGC)
@@ -394,10 +395,10 @@ typedef struct _xglPixmap {
} xglPixmapRec, *xglPixmapPtr;
-extern int xglPixmapPrivateIndex;
+extern DevPrivateKey xglPixmapPrivateKey;
-#define XGL_GET_PIXMAP_PRIV(pPixmap) \
- ((xglPixmapPtr) (pPixmap)->devPrivates[xglPixmapPrivateIndex].ptr)
+#define XGL_GET_PIXMAP_PRIV(pPixmap) ((xglPixmapPtr) \
+ dixLookupPrivate(&(pPixmap)->devPrivates, xglPixmapPrivateKey))
#define XGL_PIXMAP_PRIV(pPixmap) \
xglPixmapPtr pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap)
@@ -409,10 +410,10 @@ typedef struct _xglWin {
PixmapPtr pPixmap;
} xglWinRec, *xglWinPtr;
-extern int xglWinPrivateIndex;
+extern DevPrivateKey xglWinPrivateKey;
-#define XGL_GET_WINDOW_PRIV(pWin) \
- ((xglWinPtr) (pWin)->devPrivates[xglWinPrivateIndex].ptr)
+#define XGL_GET_WINDOW_PRIV(pWin) ((xglWinPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, xglWinPrivateKey))
#define XGL_WINDOW_PRIV(pWin) \
xglWinPtr pWinPriv = XGL_GET_WINDOW_PRIV (pWin)
diff --git a/hw/xgl/xglinput.c b/hw/xgl/xglinput.c
index cda21ad49..9499fcf1f 100644
--- a/hw/xgl/xglinput.c
+++ b/hw/xgl/xglinput.c
@@ -224,7 +224,7 @@ xglKeybdProc (DeviceIntPtr pDevice,
switch (onoff) {
case DEVICE_INIT:
- if (pDev != LookupKeyboardDevice ())
+ if (pDev != (DevicePtr)inputInfo.keyboard)
return !Success;
ret = InitKeyboardDeviceStruct (pDev,
diff --git a/hw/xgl/xglpixmap.c b/hw/xgl/xglpixmap.c
index fe2a7b1c0..8e602cee3 100644
--- a/hw/xgl/xglpixmap.c
+++ b/hw/xgl/xglpixmap.c
@@ -312,6 +312,7 @@ xglDestroyPixmap (PixmapPtr pPixmap)
xglFiniPixmap (pPixmap);
+ dixFreePrivates(pPixmap->devPrivates);
xfree (pPixmap);
return TRUE;
diff --git a/hw/xgl/xglscreen.c b/hw/xgl/xglscreen.c
index cd3b59a34..47ed34508 100644
--- a/hw/xgl/xglscreen.c
+++ b/hw/xgl/xglscreen.c
@@ -463,7 +463,8 @@ xglCreateSolidAlphaPicture (ScreenPtr pScreen)
tmpval[0] = xTrue;
pScreenPriv->pSolidAlpha = CreatePicture (0, &pPixmap->drawable, pFormat,
- CPRepeat, tmpval, 0, &error);
+ CPRepeat, tmpval,
+ serverClient, &error);
(*pScreen->DestroyPixmap) (pPixmap);
if (pScreenPriv->pSolidAlpha)
diff --git a/hw/xgl/xglxv.c b/hw/xgl/xglxv.c
index 8138a0cbb..353f9b3bb 100644
--- a/hw/xgl/xglxv.c
+++ b/hw/xgl/xglxv.c
@@ -35,11 +35,11 @@
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
-static unsigned int xglXvScreenIndex = 0;
+static DevPrivateKey xglXvScreenKey;
static unsigned long portResource = 0;
-#define XGL_GET_XV_SCREEN(pScreen) \
- ((XvScreenPtr) ((pScreen)->devPrivates[xglXvScreenIndex].ptr))
+#define XGL_GET_XV_SCREEN(pScreen) ((XvScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xglXvScreenKey))
#define XGL_XV_SCREEN(pScreen) \
XvScreenPtr pXvScreen = XGL_GET_XV_SCREEN (pScreen)
@@ -591,7 +591,7 @@ xglXvScreenInit (ScreenPtr pScreen)
if (status != Success)
return FALSE;
- xglXvScreenIndex = XvGetScreenIndex ();
+ xglXvScreenKey = XvGetScreenKey ();
portResource = XvGetRTPort ();
pXvScreen = XGL_GET_XV_SCREEN (pScreen);
diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c
index 134276e7b..138698068 100644
--- a/hw/xnest/Cursor.c
+++ b/hw/xnest/Cursor.c
@@ -104,8 +104,8 @@ xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
bg_color.green = pCursor->backGreen;
bg_color.blue = pCursor->backBlue;
- pCursor->devPriv[pScreen->myNum] = (pointer)xalloc(sizeof(xnestPrivCursor));
- xnestCursorPriv(pCursor, pScreen)->cursor =
+ xnestSetCursorPriv(pCursor, pScreen, xalloc(sizeof(xnestPrivCursor)));
+ xnestCursor(pCursor, pScreen) =
XCreatePixmapCursor(xnestDisplay, source, mask, &fg_color, &bg_color,
pCursor->bits->xhot, pCursor->bits->yhot);
@@ -119,7 +119,7 @@ Bool
xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
{
XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen));
- xfree(xnestCursorPriv(pCursor, pScreen));
+ xfree(xnestGetCursorPriv(pCursor, pScreen));
return True;
}
diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c
index a52ce1f35..06e6e0205 100644
--- a/hw/xnest/GC.c
+++ b/hw/xnest/GC.c
@@ -35,7 +35,7 @@ is" without express or implied warranty.
#include "XNFont.h"
#include "Color.h"
-int xnestGCPrivateIndex;
+DevPrivateKey xnestGCPrivateKey = &xnestGCPrivateKey;
static GCFuncs xnestFuncs = {
xnestValidateGC,
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index d1fd75732..7b344e25f 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -74,8 +74,6 @@ InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
break;
}
- xnestWindowPrivateIndex = AllocateWindowPrivateIndex();
- xnestGCPrivateIndex = AllocateGCPrivateIndex();
xnestFontPrivateIndex = AllocateFontPrivateIndex();
if (!xnestNumScreens) xnestNumScreens = 1;
diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c
index 922975262..04311966d 100644
--- a/hw/xnest/Pixmap.c
+++ b/hw/xnest/Pixmap.c
@@ -24,6 +24,7 @@ is" without express or implied warranty.
#include "regionstr.h"
#include "gc.h"
#include "servermd.h"
+#include "privates.h"
#include "mi.h"
#include "Xnest.h"
@@ -32,7 +33,7 @@ is" without express or implied warranty.
#include "Screen.h"
#include "XNPixmap.h"
-int xnestPixmapPrivateIndex;
+DevPrivateKey xnestPixmapPrivateKey = &xnestPixmapPrivateKey;
PixmapPtr
xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
@@ -56,9 +57,9 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pPixmap->refcnt = 1;
pPixmap->devKind = PixmapBytePad(width, depth);
- pPixmap->devPrivates[xnestPixmapPrivateIndex].ptr =
- (pointer)((char *)pPixmap + pScreen->totalPixmapSize);
pPixmap->usage_hint = usage_hint;
+ dixSetPrivate(&pPixmap->devPrivates, xnestPixmapPrivateKey,
+ (char *)pPixmap + pScreen->totalPixmapSize);
if (width && height)
xnestPixmapPriv(pPixmap)->pixmap =
XCreatePixmap(xnestDisplay,
@@ -76,6 +77,7 @@ xnestDestroyPixmap(PixmapPtr pPixmap)
if(--pPixmap->refcnt)
return TRUE;
XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index 02e82d193..61a325f3c 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -45,8 +45,6 @@ is" without express or implied warranty.
Window xnestDefaultWindows[MAXSCREENS];
Window xnestScreenSaverWindows[MAXSCREENS];
-static int xnestScreenGeneration = -1;
-
ScreenPtr
xnestScreen(Window window)
{
@@ -142,21 +140,13 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[])
VisualID defaultVisual;
int rootDepth;
- if (!(AllocateWindowPrivate(pScreen, xnestWindowPrivateIndex,
- sizeof(xnestPrivWin)) &&
- AllocateGCPrivate(pScreen, xnestGCPrivateIndex,
- sizeof(xnestPrivGC))))
+ if (!dixRequestPrivate(xnestWindowPrivateKey, sizeof(xnestPrivWin)))
+ return False;
+ if (!dixRequestPrivate(xnestGCPrivateKey, sizeof(xnestPrivGC)))
return False;
-
- if (xnestScreenGeneration != serverGeneration) {
- if ((xnestPixmapPrivateIndex = AllocatePixmapPrivateIndex()) < 0)
- return False;
- xnestScreenGeneration = serverGeneration;
- }
-
- if (!AllocatePixmapPrivate(pScreen,xnestPixmapPrivateIndex,
- sizeof (xnestPrivPixmap)))
+ if (!dixRequestPrivate(xnestPixmapPrivateKey, sizeof (xnestPrivPixmap)))
return False;
+
visuals = (VisualPtr)xalloc(xnestNumVisuals * sizeof(VisualRec));
numVisuals = 0;
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index e83fb90d5..bc9d8bed2 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -39,7 +39,7 @@ is" without express or implied warranty.
#include "Events.h"
#include "Args.h"
-int xnestWindowPrivateIndex;
+DevPrivateKey xnestWindowPrivateKey = &xnestWindowPrivateKey;
static int
xnestFindWindowMatch(WindowPtr pWin, pointer ptr)
diff --git a/hw/xnest/XNCursor.h b/hw/xnest/XNCursor.h
index ffec9eb0a..9705f6bea 100644
--- a/hw/xnest/XNCursor.h
+++ b/hw/xnest/XNCursor.h
@@ -19,11 +19,14 @@ typedef struct {
Cursor cursor;
} xnestPrivCursor;
-#define xnestCursorPriv(pCursor, pScreen) \
- ((xnestPrivCursor *)((pCursor)->devPriv[pScreen->myNum]))
+#define xnestGetCursorPriv(pCursor, pScreen) \
+ ((xnestPrivCursor *)dixLookupPrivate(&(pCursor)->devPrivates, pScreen))
+
+#define xnestSetCursorPriv(pCursor, pScreen, v) \
+ dixSetPrivate(&(pCursor)->devPrivates, pScreen, v)
#define xnestCursor(pCursor, pScreen) \
- (xnestCursorPriv(pCursor, pScreen)->cursor)
+ (xnestGetCursorPriv(pCursor, pScreen)->cursor)
Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
Bool xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
diff --git a/hw/xnest/XNGC.h b/hw/xnest/XNGC.h
index d3ac3df0b..19535fe3a 100644
--- a/hw/xnest/XNGC.h
+++ b/hw/xnest/XNGC.h
@@ -22,10 +22,10 @@ typedef struct {
int nClipRects;
} xnestPrivGC;
-extern int xnestGCPrivateIndex;
+extern DevPrivateKey xnestGCPrivateKey;
-#define xnestGCPriv(pGC) \
- ((xnestPrivGC *)((pGC)->devPrivates[xnestGCPrivateIndex].ptr))
+#define xnestGCPriv(pGC) ((xnestPrivGC *) \
+ dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey))
#define xnestGC(pGC) (xnestGCPriv(pGC)->gc)
diff --git a/hw/xnest/XNPixmap.h b/hw/xnest/XNPixmap.h
index 9eb2a3c70..614827587 100644
--- a/hw/xnest/XNPixmap.h
+++ b/hw/xnest/XNPixmap.h
@@ -15,14 +15,14 @@ is" without express or implied warranty.
#ifndef XNESTPIXMAP_H
#define XNESTPIXMAP_H
-extern int xnestPixmapPrivateIndex;
+extern DevPrivateKey xnestPixmapPrivateKey;
typedef struct {
Pixmap pixmap;
} xnestPrivPixmap;
-#define xnestPixmapPriv(pPixmap) \
- ((xnestPrivPixmap *)((pPixmap)->devPrivates[xnestPixmapPrivateIndex].ptr))
+#define xnestPixmapPriv(pPixmap) ((xnestPrivPixmap *) \
+ dixLookupPrivate(&(pPixmap)->devPrivates, xnestPixmapPrivateKey))
#define xnestPixmap(pPixmap) (xnestPixmapPriv(pPixmap)->pixmap)
diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h
index 6c63f1f76..4cb66c8ce 100644
--- a/hw/xnest/XNWindow.h
+++ b/hw/xnest/XNWindow.h
@@ -35,10 +35,10 @@ typedef struct {
Window window;
} xnestWindowMatch;
-extern int xnestWindowPrivateIndex;
+extern DevPrivateKey xnestWindowPrivateKey;
-#define xnestWindowPriv(pWin) \
- ((xnestPrivWin *)((pWin)->devPrivates[xnestWindowPrivateIndex].ptr))
+#define xnestWindowPriv(pWin) ((xnestPrivWin *) \
+ dixLookupPrivate(&(pWin)->devPrivates, xnestWindowPrivateKey))
#define xnestWindow(pWin) (xnestWindowPriv(pWin)->window)
diff --git a/hw/xprint/attributes.c b/hw/xprint/attributes.c
index 4c6ad46a9..e79360496 100644
--- a/hw/xprint/attributes.c
+++ b/hw/xprint/attributes.c
@@ -124,7 +124,7 @@ 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;
+static DevPrivateKey attrCtxtPrivKey = &attrCtxtPrivKey;
/*
* The ContextAttrs structure descibes the context private space reserved
@@ -521,8 +521,7 @@ XpBuildAttributeStore(
{
if(attrList != (PrAttrPtr)NULL)
FreeAttrList();
- attrCtxtPrivIndex = XpAllocateContextPrivateIndex();
- XpAllocateContextPrivate(attrCtxtPrivIndex, sizeof(ContextAttrs));
+ dixRequestPrivate(attrCtxtPrivKey, sizeof(ContextAttrs));
BuildSystemAttributes();
attrGeneration = serverGeneration;
@@ -592,7 +591,8 @@ XpInitAttributes(XpContextPtr pContext)
PrAttrPtr pPrAttr = attrList;
/* Initialize all the pointers to NULL */
- pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs = (ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
(void)memset((void *)pCtxtAttrs, 0, (size_t) sizeof(ContextAttrs));
for(pPrAttr = attrList; pPrAttr != (PrAttrPtr)NULL; pPrAttr = pPrAttr->next)
@@ -612,8 +612,8 @@ XpDestroyAttributes(
{
ContextAttrPtr pCtxtAttrs;
- pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
-
+ pCtxtAttrs = (ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
if(pCtxtAttrs->printerAttrs != (XrmDatabase)NULL)
XrmDestroyDatabase(pCtxtAttrs->printerAttrs);
if(pCtxtAttrs->docAttrs != (XrmDatabase)NULL)
@@ -661,7 +661,8 @@ XpGetOneAttribute(
}
else
{
- pCtxtAttrs=(ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs=(ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPPrinterAttr:
@@ -714,7 +715,8 @@ XpPutOneAttribute(
XrmBinding bindings[1];
XrmQuark quarks[2];
- pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs = (ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPPrinterAttr:
@@ -900,7 +902,8 @@ XpGetAttributes(
db = systemAttributes.server;
else
{
- pCtxtAttrs=(ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs=(ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPServerAttr:
@@ -952,7 +955,8 @@ XpAugmentAttributes(
db = XrmGetStringDatabase(attributes);
if(db == (XrmDatabase)NULL) return BadAlloc;
- pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs = (ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPPrinterAttr:
@@ -988,7 +992,8 @@ XpSetAttributes(
db = XrmGetStringDatabase(attributes);
if(db == (XrmDatabase)NULL) return BadAlloc;
- pCtxtAttrs=(ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs=(ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPPrinterAttr:
diff --git a/hw/xprint/pcl/Pcl.h b/hw/xprint/pcl/Pcl.h
index 0c50ed241..d46a03401 100644
--- a/hw/xprint/pcl/Pcl.h
+++ b/hw/xprint/pcl/Pcl.h
@@ -83,10 +83,10 @@ typedef char *XPointer;
/******
* externally visible variables from PclInit.c
******/
-extern int PclScreenPrivateIndex, PclWindowPrivateIndex;
-extern int PclContextPrivateIndex;
-extern int PclPixmapPrivateIndex;
-extern int PclGCPrivateIndex;
+extern DevPrivateKey PclScreenPrivateKey, PclWindowPrivateKey;
+extern DevPrivateKey PclContextPrivateKey;
+extern DevPrivateKey PclPixmapPrivateKey;
+extern DevPrivateKey PclGCPrivateKey;
/******
* externally visible variables from PclAttVal.c
diff --git a/hw/xprint/pcl/PclArc.c b/hw/xprint/pcl/PclArc.c
index 0d8289e33..20d3f723d 100644
--- a/hw/xprint/pcl/PclArc.c
+++ b/hw/xprint/pcl/PclArc.c
@@ -85,7 +85,7 @@ PclDoArc(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
XpGetReproductionArea( pCon, &repro );
/*
diff --git a/hw/xprint/pcl/PclColor.c b/hw/xprint/pcl/PclColor.c
index 8b05da056..5e8ffa63c 100644
--- a/hw/xprint/pcl/PclColor.c
+++ b/hw/xprint/pcl/PclColor.c
@@ -129,8 +129,8 @@ PclCreateColormap(ColormapPtr pColor)
PclCmapToContexts *new;
PclScreenPrivPtr sPriv;
- sPriv = (PclScreenPrivPtr)pColor->pScreen
- ->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pColor->pScreen->devPrivates, PclScreenPrivateKey);
/*
* Use existing code to initialize the values in the colormap
@@ -175,8 +175,8 @@ PclDestroyColormap(ColormapPtr pColor)
/*
* Find the colormap <-> contexts mapping
*/
- sPriv = (PclScreenPrivPtr)pColor->pScreen
- ->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pColor->pScreen->devPrivates, PclScreenPrivateKey);
pCmap = sPriv->colormaps;
while( pCmap )
{
@@ -195,8 +195,8 @@ PclDestroyColormap(ColormapPtr pColor)
con = pCmap->contexts;
while( con )
{
- cPriv = con->context->devPrivates[PclContextPrivateIndex].ptr;
-
+ cPriv = dixLookupPrivate(&con->context->devPrivates,
+ PclContextPrivateKey);
pPal = cPriv->palettes;
while( pPal )
{
@@ -259,8 +259,8 @@ PclStoreColors(ColormapPtr pColor,
char t[80];
int i;
- sPriv = (PclScreenPrivPtr)pColor->pScreen
- ->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pColor->pScreen->devPrivates, PclScreenPrivateKey);
p = sPriv->colormaps;
while( p )
{
@@ -278,8 +278,8 @@ PclStoreColors(ColormapPtr pColor,
* For each context, get the palette ID and update the
* appropriate palette.
*/
- cPriv = con->context
- ->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = dixLookupPrivate(&con->context->devPrivates,
+ PclContextPrivateKey);
pMap = PclFindPaletteMap( cPriv, pColor, NULL );
/*
@@ -407,7 +407,8 @@ PclUpdateColormap(DrawablePtr pDrawable,
unsigned short r, g, b, rr, gg, bb;
int i;
- cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
c = wColormap( win );
cmap = (ColormapPtr)LookupIDByType( c, RT_COLORMAP );
@@ -436,8 +437,9 @@ PclUpdateColormap(DrawablePtr pDrawable,
/*
* Add the colormap to the screen-level colormap<->context mapping.
*/
- sPriv = (PclScreenPrivPtr)cmap->pScreen
- ->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&cmap->pScreen->devPrivates,
+ PclScreenPrivateKey);
pCmap = sPriv->colormaps;
while( pCmap && ( pCmap->colormapId != cmap->mid ) )
pCmap = pCmap->next;
diff --git a/hw/xprint/pcl/PclGC.c b/hw/xprint/pcl/PclGC.c
index b47f2833a..fbadf5d5d 100644
--- a/hw/xprint/pcl/PclGC.c
+++ b/hw/xprint/pcl/PclGC.c
@@ -144,7 +144,8 @@ PclGetDrawablePrivateStuff(
return FALSE;
else
{
- cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
*gc = cPriv->lastGC;
*valid = cPriv->validGC;
*file = cPriv->pPageFile;
@@ -171,7 +172,8 @@ PclSetDrawablePrivateGC(
{
case DRAWABLE_PIXMAP:
pix = (PixmapPtr)pDrawable;
- pixPriv = pix->devPrivates[PclPixmapPrivateIndex].ptr;
+ pixPriv = (PclPixmapPrivPtr)
+ dixLookupPrivate(&pix->devPrivates, PclPixmapPrivateKey);
pixPriv->lastGC = gc;
pixPriv->validGC = 1;
@@ -179,8 +181,8 @@ PclSetDrawablePrivateGC(
case DRAWABLE_WINDOW:
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
- pPriv = ((PclContextPrivPtr)
- (pCon->devPrivates[PclContextPrivateIndex].ptr));
+ pPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pPriv->validGC = 1;
pPriv->lastGC = gc;
@@ -316,13 +318,14 @@ PclUpdateDrawableGC(
XpContextPtr pCon;
PclContextPrivPtr cPriv;
PclGCPrivPtr gcPriv = (PclGCPrivPtr)
- (pGC->devPrivates[PclGCPrivateIndex].ptr);
+ dixLookupPrivate(&pGC->devPrivates, PclGCPrivateKey);
if( !PclGetDrawablePrivateStuff( pDrawable, &dGC, &valid, outFile ) )
return FALSE;
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
- cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Here's where we update the colormap. Since there can be
diff --git a/hw/xprint/pcl/PclInit.c b/hw/xprint/pcl/PclInit.c
index 574b481d2..e738e3e54 100644
--- a/hw/xprint/pcl/PclInit.c
+++ b/hw/xprint/pcl/PclInit.c
@@ -67,11 +67,11 @@ 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;
+DevPrivateKey PclScreenPrivateKey = &PclScreenPrivateKey;
+DevPrivateKey PclContextPrivateKey = &PclContextPrivateKey;
+DevPrivateKey PclPixmapPrivateKey = &PclPixmapPrivateKey;
+DevPrivateKey PclWindowPrivateKey = &PclWindowPrivateKey;
+DevPrivateKey PclGCPrivateKey = &PclGCPrivateKey;
#ifdef XP_PCL_COLOR
/*
@@ -119,7 +119,8 @@ Bool
PclCloseScreen(int index,
ScreenPtr pScreen)
{
- PclScreenPrivPtr pPriv = pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+ PclScreenPrivPtr pPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PclScreenPrivateKey);
pScreen->CloseScreen = pPriv->CloseScreen;
xfree( pPriv );
@@ -157,8 +158,8 @@ InitializePclDriver(
*/
AllocatePclPrivates(pScreen);
- pPriv =
- (PclScreenPrivPtr)pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+ pPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PclScreenPrivateKey);
maxDim = MAX( pScreen->height, pScreen->width );
xRes = pScreen->width / ( pScreen->mmWidth / 25.4 );
@@ -258,33 +259,13 @@ InitializePclDriver(
static void
AllocatePclPrivates(ScreenPtr pScreen)
{
- static unsigned long PclGeneration = 0;
+ dixRequestPrivate(PclWindowPrivateKey, sizeof( PclWindowPrivRec ) );
+ dixRequestPrivate(PclContextPrivateKey, sizeof( PclContextPrivRec ) );
+ dixRequestPrivate(PclGCPrivateKey, sizeof( PclGCPrivRec ) );
+ dixRequestPrivate(PclPixmapPrivateKey, sizeof( PclPixmapPrivRec ) );
- 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));
+ dixSetPrivate(&pScreen->devPrivates, PclScreenPrivateKey,
+ xalloc(sizeof(PclScreenPrivRec)));
}
/*
@@ -347,8 +328,8 @@ PclInitContext(XpContextPtr pCon)
/*
* Set up the context privates
*/
- pConPriv =
- (PclContextPrivPtr)pCon->devPrivates[PclContextPrivateIndex].ptr;
+ pConPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pConPriv->jobFileName = (char *)NULL;
pConPriv->pageFileName = (char *)NULL;
@@ -481,7 +462,7 @@ static Bool
PclDestroyContext(XpContextPtr pCon)
{
PclContextPrivPtr pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
PclPaletteMapPtr p, t;
PclCmapToContexts *pCmap;
ScreenPtr screen;
@@ -539,7 +520,8 @@ PclDestroyContext(XpContextPtr pCon)
* Remove the context from the screen-level colormap<->contexts mappings
*/
screen = screenInfo.screens[pCon->screenNum];
- sPriv = (PclScreenPrivPtr)screen->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&screen->devPrivates, PclScreenPrivateKey);
pCmap = sPriv->colormaps;
while( pCmap )
{
@@ -581,8 +563,8 @@ PclGetContextFromWindow(WindowPtr win)
while( win )
{
- pPriv =
- (PclWindowPrivPtr)win->devPrivates[PclWindowPrivateIndex].ptr;
+ pPriv = (PclWindowPrivPtr)
+ dixLookupPrivate(&win->devPrivates, PclWindowPrivateKey);
if( pPriv->validContext )
return pPriv->context;
diff --git a/hw/xprint/pcl/PclLine.c b/hw/xprint/pcl/PclLine.c
index 52a586d17..68d55a525 100644
--- a/hw/xprint/pcl/PclLine.c
+++ b/hw/xprint/pcl/PclLine.c
@@ -107,7 +107,7 @@ PclPolyLine(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Allocate the storage required to deal with the clipping
@@ -223,7 +223,7 @@ PclPolySegment(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Allocate the storage for the temporary regions.
diff --git a/hw/xprint/pcl/PclPixel.c b/hw/xprint/pcl/PclPixel.c
index f41af272f..d219838f0 100644
--- a/hw/xprint/pcl/PclPixel.c
+++ b/hw/xprint/pcl/PclPixel.c
@@ -125,13 +125,15 @@ PclPolyPoint( pDrawable, pGC, mode, nPoints, pPoints )
if( pDrawable->type == DRAWABLE_WINDOW )
{
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
- cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
cPriv->changeMask = GCLineWidth | GCLineStyle;
}
else
{
- pPriv =
- ((PixmapPtr)pDrawable)->devPrivates[PclPixmapPrivateIndex].ptr;
+ pPriv = (PclPixmapPrivPtr)
+ dixLookupPrivate(&((PixmapPtr)pDrawable)->devPrivates,
+ PclPixmapPrivateKey);
pPriv->changeMask = GCLineWidth | GCLineStyle;
}
#endif
diff --git a/hw/xprint/pcl/PclPolygon.c b/hw/xprint/pcl/PclPolygon.c
index 9867758bb..7d95d6484 100644
--- a/hw/xprint/pcl/PclPolygon.c
+++ b/hw/xprint/pcl/PclPolygon.c
@@ -76,7 +76,7 @@ PclPolyRectangle(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Allocate the storage required to deal with the clipping
@@ -170,7 +170,7 @@ PclFillPolygon(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Generate the PCL code to draw the filled polygon, by defining
@@ -283,7 +283,7 @@ PclPolyFillRect(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Allocate the storage required to deal with the clipping
diff --git a/hw/xprint/pcl/PclPrint.c b/hw/xprint/pcl/PclPrint.c
index 176a0025a..ac8ea1537 100644
--- a/hw/xprint/pcl/PclPrint.c
+++ b/hw/xprint/pcl/PclPrint.c
@@ -72,8 +72,8 @@ PclStartJob(
Bool sendClientData,
ClientPtr client)
{
- PclContextPrivPtr pConPriv =
- (PclContextPrivPtr)pCon->devPrivates[PclContextPrivateIndex].ptr;
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
PclPaletteMap *pal;
/*
@@ -130,7 +130,7 @@ PclEndJob(
Bool cancel)
{
PclContextPrivPtr priv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
#ifdef CCP_DEBUG
FILE *xpoutput;
@@ -250,9 +250,9 @@ PclStartPage(
WindowPtr pWin)
{
PclContextPrivPtr pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
- PclWindowPrivPtr pWinPriv =
- (PclWindowPrivPtr)pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
+ PclWindowPrivPtr pWinPriv = (PclWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PclWindowPrivateKey);
xRectangle repro;
char t[80];
XpOid orient, plex, tray, medium;
@@ -488,7 +488,7 @@ PclEndPage(
WindowPtr pWin)
{
PclContextPrivPtr pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
struct stat statBuf;
@@ -532,7 +532,7 @@ PclStartDoc(XpContextPtr pCon,
XPDocumentType type)
{
PclContextPrivPtr pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
#ifndef XP_PCL_LJ3
/*
@@ -592,7 +592,7 @@ PclDocumentData(
{
int type = 0;
PclContextPrivPtr pPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
XpOidDocFmtList *formats;
XpOidDocFmt *f;
char t[80];
@@ -700,7 +700,7 @@ PclGetDocumentData(
int maxBufferSize)
{
PclContextPrivPtr pPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pPriv->getDocClient = client;
pPriv->getDocBufSize = maxBufferSize;
diff --git a/hw/xprint/pcl/PclText.c b/hw/xprint/pcl/PclText.c
index 246c0195b..324de3014 100644
--- a/hw/xprint/pcl/PclText.c
+++ b/hw/xprint/pcl/PclText.c
@@ -123,7 +123,7 @@ char font_type;
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pSoftFontInfo = pConPriv->pSoftFontInfo;
font_type = isInternal(pGC->font);
if ( font_type == DOWNLOAD_FONT ) {
@@ -293,7 +293,7 @@ char font_type;
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pSoftFontInfo = pConPriv->pSoftFontInfo;
font_type = isInternal(pGC->font);
diff --git a/hw/xprint/pcl/PclWindow.c b/hw/xprint/pcl/PclWindow.c
index f34ad7feb..a87dc0e7a 100644
--- a/hw/xprint/pcl/PclWindow.c
+++ b/hw/xprint/pcl/PclWindow.c
@@ -97,9 +97,9 @@ PclCreateWindow(
Bool status = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
PclScreenPrivPtr pScreenPriv = (PclScreenPrivPtr)
- pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, PclScreenPrivateKey);
PclWindowPrivPtr pWinPriv = (PclWindowPrivPtr)
- pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ dixLookupPrivate(&pWin->devPrivates, PclWindowPrivateKey);
/*
* Initialize this window's private struct.
@@ -142,7 +142,8 @@ PclCreateWindow(
/*
* Invalidate the window's private print context.
*/
- pPriv = (PclWindowPrivPtr)pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ pPriv = (PclWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PclWindowPrivateKey);
pPriv->validContext = 0;
return TRUE;
diff --git a/hw/xprint/pcl/Pclmap.h b/hw/xprint/pcl/Pclmap.h
index 3990ab294..18ac31d90 100644
--- a/hw/xprint/pcl/Pclmap.h
+++ b/hw/xprint/pcl/Pclmap.h
@@ -82,11 +82,11 @@ copyright holders.
#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)
+#define PclScreenPrivateKey PCLNAME(ScreenPrivateKey)
+#define PclWindowPrivateKey PCLNAME(WindowPrivateKey)
+#define PclContextPrivateKey PCLNAME(ContextPrivateKey)
+#define PclPixmapPrivateKey PCLNAME(PixmapPrivateKey)
+#define PclGCPrivateKey PCLNAME(GCPrivateKey)
/* PclPrint.c */
#define PclStartJob PCLNAME(StartJob)
diff --git a/hw/xprint/ps/Ps.h b/hw/xprint/ps/Ps.h
index 5e77d9a0a..a25e9891a 100644
--- a/hw/xprint/ps/Ps.h
+++ b/hw/xprint/ps/Ps.h
@@ -121,10 +121,10 @@ typedef char *XPointer;
* Public index variables from PsInit.c
*/
-extern int PsScreenPrivateIndex;
-extern int PsWindowPrivateIndex;
-extern int PsContextPrivateIndex;
-extern int PsPixmapPrivateIndex;
+extern DevPrivateKey PsScreenPrivateKey;
+extern DevPrivateKey PsWindowPrivateKey;
+extern DevPrivateKey PsContextPrivateKey;
+extern DevPrivateKey PsPixmapPrivateKey;
extern XpValidatePoolsRec PsValidatePoolsRec;
/*
diff --git a/hw/xprint/ps/PsGC.c b/hw/xprint/ps/PsGC.c
index 3ec07a77a..19898c90e 100644
--- a/hw/xprint/ps/PsGC.c
+++ b/hw/xprint/ps/PsGC.c
@@ -162,9 +162,11 @@ PsGetDrawablePrivateStuff(
c = wColormap((WindowPtr)pDrawable);
cmap = (ColormapPtr)LookupIDByType(c, RT_COLORMAP);
- cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
+ cPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
sPriv = (PsScreenPrivPtr)
- pDrawable->pScreen->devPrivates[PsScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pDrawable->pScreen->devPrivates,
+ PsScreenPrivateKey);
*gc = cPriv->lastGC;
*valid = cPriv->validGC;
*psOut = cPriv->pPsOut;
@@ -189,7 +191,8 @@ PsGetPsContextPriv( DrawablePtr pDrawable )
pCon = PsGetContextFromWindow((WindowPtr)pDrawable);
if (pCon != NULL)
{
- return pCon->devPrivates[PsContextPrivateIndex].ptr;
+ return (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
}
}
return NULL;
@@ -257,8 +260,9 @@ PsUpdateDrawableGC(
PsOut_Offset(*psOut, pDrawable->x, pDrawable->y);
PsOut_Clip(*psOut, pGC->clientClipType, (PsClipPtr)pGC->clientClip);
}
- cPriv = ( PsGetContextFromWindow( (WindowPtr)pDrawable ) )
- ->devPrivates[PsContextPrivateIndex].ptr;
+ cPriv = (PsContextPrivPtr)dixLookupPrivate(
+ &PsGetContextFromWindow((WindowPtr)pDrawable)->devPrivates,
+ PsContextPrivateKey);
break;
}
return TRUE;
diff --git a/hw/xprint/ps/PsInit.c b/hw/xprint/ps/PsInit.c
index 6d4bd06f3..72bd7bd7c 100644
--- a/hw/xprint/ps/PsInit.c
+++ b/hw/xprint/ps/PsInit.c
@@ -97,10 +97,10 @@ static void AllocatePsPrivates(ScreenPtr pScreen);
static int PsInitContext(XpContextPtr pCon);
static int PsDestroyContext(XpContextPtr pCon);
-int PsScreenPrivateIndex;
-int PsContextPrivateIndex;
-int PsPixmapPrivateIndex;
-int PsWindowPrivateIndex;
+DevPrivateKey PsScreenPrivateKey = &PsScreenPrivateKey;
+DevPrivateKey PsContextPrivateKey = &PsContextPrivateKey;
+DevPrivateKey PsPixmapPrivateKey = &PsPixmapPrivateKey;
+DevPrivateKey PsWindowPrivateKey = &PsWindowPrivateKey;
#ifdef GLXEXT
extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
@@ -152,7 +152,8 @@ InitializePsDriver(ndx, pScreen, argc, argv)
AllocatePsPrivates(pScreen);
#if 0
- pPriv = (PsScreenPrivPtr)pScreen->devPrivates[PsScreenPrivateIndex].ptr;
+ pPriv = (PsScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PsScreenPrivateKey);
pPriv->resDB = rmdb;
#endif
@@ -474,28 +475,12 @@ InitializePsDriver(ndx, pScreen, argc, argv)
static void
AllocatePsPrivates(ScreenPtr pScreen)
{
- static unsigned long PsGeneration = 0;
+ dixRequestPrivate(PsWindowPrivateKey, sizeof(PsWindowPrivRec));
+ dixRequestPrivate(PsContextPrivateKey, sizeof(PsContextPrivRec));
+ dixRequestPrivate(PsPixmapPrivateKey, sizeof(PsPixmapPrivRec));
- 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));
+ dixSetPrivate(&pScreen->devPrivates, PsScreenPrivateKey,
+ xalloc(sizeof(PsScreenPrivRec)));
}
/*
@@ -550,8 +535,8 @@ PsInitContext(pCon)
/*
* Set up the context privates
*/
- pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
memset(pConPriv, 0, sizeof(PsContextPrivRec));
pConPriv->jobFileName = (char *)NULL;
@@ -620,8 +605,8 @@ static Bool
PsDestroyContext(pCon)
XpContextPtr pCon;
{
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
if( pConPriv->pJobFile!=(FILE *)NULL )
{
@@ -653,7 +638,8 @@ PsGetContextFromWindow(win)
while( win )
{
- pPriv = (PsWindowPrivPtr)win->devPrivates[PsWindowPrivateIndex].ptr;
+ pPriv = (PsWindowPrivPtr)
+ dixLookupPrivate(&win->devPrivates, PsWindowPrivateKey);
if( pPriv->validContext ) return pPriv->context;
win = win->parent;
}
diff --git a/hw/xprint/ps/PsPixmap.c b/hw/xprint/ps/PsPixmap.c
index d3ab198f8..a588f4276 100644
--- a/hw/xprint/ps/PsPixmap.c
+++ b/hw/xprint/ps/PsPixmap.c
@@ -79,6 +79,7 @@ in this Software without prior written authorization from The Open Group.
#include "windowstr.h"
#include "gcstruct.h"
+#include "privates.h"
#include "Ps.h"
@@ -111,6 +112,7 @@ PsCreatePixmap(
pPixmap->drawable.height = height;
pPixmap->devKind = 0;
pPixmap->refcnt = 1;
+ pPixmap->devPrivates = NULL;
pPixmap->devPrivate.ptr = (PsPixmapPrivPtr)xcalloc(1, sizeof(PsPixmapPrivRec));
if( !pPixmap->devPrivate.ptr )
@@ -197,6 +199,7 @@ PsDestroyPixmap(PixmapPtr pPixmap)
PsScrubPixmap(pPixmap);
xfree(priv);
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/hw/xprint/ps/PsPrint.c b/hw/xprint/ps/PsPrint.c
index 4571c07d7..386646858 100644
--- a/hw/xprint/ps/PsPrint.c
+++ b/hw/xprint/ps/PsPrint.c
@@ -165,8 +165,8 @@ PsStartJob(
Bool sendClientData,
ClientPtr client)
{
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
/*
* Create a temporary file to store the printer output.
@@ -191,8 +191,8 @@ PsEndJob(
struct stat buffer;
int error;
- PsContextPrivPtr priv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsContextPrivPtr priv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
if (cancel == True) {
if (priv->getDocClient != (ClientPtr) NULL) {
@@ -291,10 +291,10 @@ PsStartPage(
{
int iorient, iplex, icount, ires;
unsigned short iwd, iht;
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
- PsWindowPrivPtr pWinPriv =
- (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
+ PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey);
/*
* Put a pointer to the context in the window private structure
@@ -337,10 +337,10 @@ PsEndPage(
XpContextPtr pCon,
WindowPtr pWin)
{
- PsWindowPrivPtr pWinPriv =
- (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey);
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
PsOut_EndPage(pConPriv->pPsOut);
@@ -366,8 +366,8 @@ PsStartDoc(XpContextPtr pCon, XPDocumentType type)
int iorient, iplex, icount, ires;
unsigned short iwd, iht;
char *title;
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
/* get job level attributes */
title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");
@@ -420,7 +420,8 @@ PsDocumentData(
len_opt)
return BadValue;
- cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
+ cPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
psOut = cPriv->pPsOut;
if (pDraw)
@@ -448,7 +449,7 @@ PsGetDocumentData(
int maxBufferSize)
{
PsContextPrivPtr pPriv = (PsContextPrivPtr)
- pCon->devPrivates[PsContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
pPriv->getDocClient = client;
pPriv->getDocBufSize = maxBufferSize;
diff --git a/hw/xprint/ps/PsWindow.c b/hw/xprint/ps/PsWindow.c
index ded7dd638..d17cf8ce0 100644
--- a/hw/xprint/ps/PsWindow.c
+++ b/hw/xprint/ps/PsWindow.c
@@ -123,9 +123,9 @@ PsCreateWindow(WindowPtr pWin)
Bool status = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
PsScreenPrivPtr pScreenPriv = (PsScreenPrivPtr)
- pScreen->devPrivates[PsScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, PsScreenPrivateKey);
PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)
- pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey);
/*
* Initialize this window's private struct.
@@ -165,7 +165,8 @@ PsCreateWindow(WindowPtr pWin)
return status;
#endif
- pPriv = (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ pPriv = (PsWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey);
pPriv->validContext = 0;
return TRUE;
diff --git a/hw/xprint/raster/Raster.c b/hw/xprint/raster/Raster.c
index 0286a18fa..dccef613c 100644
--- a/hw/xprint/raster/Raster.c
+++ b/hw/xprint/raster/Raster.c
@@ -151,8 +151,8 @@ static int RasterReproducibleArea(XpContextPtr pCon,
#define DOC_PCL 1
#define DOC_RASTER 2
-static int RasterScreenPrivateIndex, RasterContextPrivateIndex;
-static int RasterGeneration = 0;
+static DevPrivateKey RasterScreenPrivateKey = &RasterScreenPrivateKey;
+static DevPrivateKey RasterContextPrivateKey = &RasterContextPrivateKey;
static char RASTER_DRIV_NAME[] = "XP-RASTER";
static int doc_type = DOC_RASTER;
@@ -205,7 +205,7 @@ InitializeRasterDriver(
AllocateRasterPrivates(pScreen);
pPriv = (RasterScreenPrivPtr)
- pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, RasterScreenPrivateKey);
maxDim = MAX( pScreen->height, pScreen->width );
numBytes = maxDim + BITMAP_SCANLINE_PAD - 1; /* pixels per row */
@@ -252,7 +252,7 @@ GetPropString(
char *propName)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
char *type;
XrmValue val;
struct stat status;
@@ -371,7 +371,7 @@ StartJob(
ClientPtr client)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
SetDocumentType( pCon );
@@ -488,7 +488,7 @@ EndJob(
Bool cancel)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
if( cancel == True )
{
@@ -549,7 +549,7 @@ StartPage(
WindowPtr pWin)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
if(pConPriv->pPageFile != (FILE *)NULL)
{
@@ -830,7 +830,7 @@ SendPage( XpContextPtr pCon )
{
struct stat statBuf;
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
if(stat(pConPriv->pageFileName, &statBuf) < 0)
return BadAlloc;
@@ -872,7 +872,7 @@ EndPage(
WindowPtr pWin)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
struct stat statBuf;
char *rasterFileName = (char *)NULL, *pCommand = (char *)NULL;
FILE *pRasterFile = (FILE *)NULL;
@@ -1068,7 +1068,7 @@ DocumentData(
ClientPtr client)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
char *preRasterStr = PRE_RASTER, *postRasterStr = POST_RASTER,
*noRasterStr = NO_RASTER;
@@ -1135,7 +1135,7 @@ GetDocumentData(
int maxBufferSize)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pContext->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pContext->devPrivates, RasterContextPrivateKey);
pConPriv->getDocClient = client;
pConPriv->getDocBufSize = maxBufferSize;
@@ -1146,17 +1146,9 @@ 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));
+ dixRequestPrivate(RasterContextPrivateKey, sizeof( RasterContextPrivRec ) );
+ dixSetPrivate(&pScreen->devPrivates, RasterScreenPrivateKey,
+ Xalloc(sizeof(RasterScreenPrivRec)));
}
/*
@@ -1171,7 +1163,7 @@ RasterChangeWindowAttributes(
Bool status = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
RasterScreenPrivPtr pScreenPriv = (RasterScreenPrivPtr)
- pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, RasterScreenPrivateKey);
if(pWin->backingStore == NotUseful)
{
@@ -1270,7 +1262,7 @@ RasterInitContext(
* Set up the context privates
*/
pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
pConPriv->jobFileName = (char *)NULL;
pConPriv->pageFileName = (char *)NULL;
@@ -1355,7 +1347,7 @@ RasterDestroyContext(
XpContextPtr pCon)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
/*
* Clean up the temporary files
@@ -1477,7 +1469,7 @@ RasterCloseScreen(
{
Bool status = Success;
RasterScreenPrivPtr pScreenPriv = (RasterScreenPrivPtr)
- pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, RasterScreenPrivateKey);
/*
* Call any wrapped CloseScreen proc.
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 299d9838d..ab4dc0dfd 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -195,7 +195,7 @@ static Bool DarwinAddScreen(
dfb = xalloc(sizeof(DarwinFramebufferRec));
// SCREEN_PRIV(pScreen) = dfb;
- pScreen->devPrivates[darwinScreenIndex].ptr = dfb;
+ dixSetPrivate(&pScreen->devPrivates, darwinScreenKey, dfb);
// setup hardware/mode specific details
ret = QuartzAddScreen(foundIndex, pScreen);
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index f835ae01e..c569d66df 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -52,13 +52,13 @@ int DarwinParseModifierList(const char *constmodifiers);
void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
-#define SCREEN_PRIV(pScreen) \
- ((DarwinFramebufferPtr)pScreen->devPrivates[darwinScreenIndex].ptr)
+#define SCREEN_PRIV(pScreen) ((DarwinFramebufferPtr) \
+ dixLookupPrivate(&pScreen->devPrivates, darwinScreenKey))
/*
* Global variables from darwin.c
*/
-extern int darwinScreenIndex; // index into pScreen.devPrivates
+extern DevPrivateKey darwinScreenKey; // index into pScreen.devPrivates
extern int darwinScreensFound;
extern io_connect_t darwinParamConnect;
extern int darwinEventReadFD;
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 1d09e0941..1760792c6 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -289,7 +289,7 @@ void ProcessInputEvents(void) {
while (darwinEventQueue.head != darwinEventQueue.tail)
{
if (screenIsSaved == SCREEN_SAVER_ON)
- SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
+ dixSaveScreens (serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
e = &darwinEventQueue.events[darwinEventQueue.head];
xe = e->event;
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 7be91ec6d..206330056 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -68,7 +68,7 @@ int quartzUseAGL = 1;
int quartzEnableKeyEquivalents = 1;
int quartzServerVisible = TRUE;
int quartzServerQuitting = FALSE;
-int quartzScreenIndex = 0;
+DevPrivateKey quartzScreenKey = &quartzScreenKey;
int aquaMenuBarHeight = 0;
int noPseudoramiXExtension = FALSE;
QuartzModeProcsPtr quartzProcs = NULL;
@@ -118,7 +118,7 @@ Bool QuartzAddScreen(
QuartzScreenPtr displayInfo = xcalloc(sizeof(QuartzScreenRec), 1);
// QUARTZ_PRIV(pScreen) = displayInfo;
- pScreen->devPrivates[quartzScreenIndex].ptr = displayInfo;
+ dixSetPrivate(&pScreen->devPrivates, quartzScreenKey, displayInfo);
// do Quartz mode specific initialization
return quartzProcs->AddScreen(index, pScreen);
@@ -153,14 +153,6 @@ void QuartzInitOutput(
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();
}
diff --git a/hw/xquartz/quartzCommon.h b/hw/xquartz/quartzCommon.h
index f0d5a7a08..50b50f610 100644
--- a/hw/xquartz/quartzCommon.h
+++ b/hw/xquartz/quartzCommon.h
@@ -47,6 +47,7 @@
#undef WindowPtr
#undef Picture
#include <X11/Xdefs.h>
+#include "privates.h"
// Quartz specific per screen storage structure
typedef struct {
@@ -59,7 +60,7 @@ typedef struct {
} QuartzScreenRec, *QuartzScreenPtr;
#define QUARTZ_PRIV(pScreen) \
- ((QuartzScreenPtr)pScreen->devPrivates[quartzScreenIndex].ptr)
+ ((QuartzScreenPtr)dixLookupPrivate(&pScreen->devPrivates, quartzScreenKey))
// Data stored at startup for Cocoa front end
extern int quartzEventWriteFD;
@@ -74,7 +75,7 @@ extern int quartzEnableKeyEquivalents;
// Other shared data
extern int quartzServerVisible;
extern int quartzServerQuitting;
-extern int quartzScreenIndex;
+extern DevPrivateKey quartzScreenKey;
extern int aquaMenuBarHeight;
// Name of GLX bundle for native OpenGL
diff --git a/hw/xquartz/quartzCursor.c b/hw/xquartz/quartzCursor.c
index 6e86acbc4..f82ccd380 100644
--- a/hw/xquartz/quartzCursor.c
+++ b/hw/xquartz/quartzCursor.c
@@ -56,8 +56,7 @@ typedef struct {
miPointerSpriteFuncPtr spriteFuncs;
} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
+static DevPrivateKey darwinCursorScreenKey = &darwinCursorScreenKey;
static CursorPtr quartzLatentCursor = NULL;
static QD_Cursor gQDArrow; // QuickDraw arrow cursor
@@ -66,8 +65,8 @@ static CCrsrHandle currentCursor = NULL;
static pthread_mutex_t cursorMutex;
static pthread_cond_t cursorCondition;
-#define CURSOR_PRIV(pScreen) \
- ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
+ dixLookupPrivate(&pScreen->devPrivates, darwinCursorScreenKey))
#define HIDE_QD_CURSOR(pScreen, visible) \
if (visible) { \
@@ -319,7 +318,7 @@ QuartzRealizeCursor(
if (!qdCursor) return FALSE;
// save the result
- pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor;
+ dixSetPrivate(&pCursor->devPrivates, pScreen, qdCursor);
return TRUE;
}
@@ -346,13 +345,13 @@ QuartzUnrealizeCursor(
(pScreen, pCursor);
}
} else {
- CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum];
-
+ CCrsrHandle oldCursor = dixLookupPrivate(&pCursor->devPrivates,
+ pScreen);
if (currentCursor != oldCursor) {
// This should only fail when quitting, in which case we just leak.
FreeQDCursor(oldCursor);
}
- pCursor->devPriv[pScreen->myNum] = NULL;
+ dixSetPrivate(&pCursor->devPrivates, pScreen, NULL);
return TRUE;
}
}
@@ -392,7 +391,7 @@ QuartzSetCursor(
(*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
ScreenPriv->qdCursorMode = TRUE;
- CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]);
+ CHANGE_QD_CURSOR(dixLookupPrivate(&pCursor->devPrivates, pScreen));
SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
}
else if (quartzRootless) {
@@ -592,13 +591,6 @@ QuartzInitCursor(
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;
@@ -611,7 +603,7 @@ QuartzInitCursor(
// initialize QuickDraw cursor handling
GetQDGlobalsArrow(&gQDArrow);
PointPriv = (miPointerScreenPtr)
- pScreen->devPrivates[miPointerScreenIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
index e5591abcb..3aacb192d 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -71,9 +71,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <AvailabilityMacros.h>
-static int DRIScreenPrivIndex = -1;
-static int DRIWindowPrivIndex = -1;
-static int DRIPixmapPrivIndex = -1;
+static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKey;
+static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKey;
+static DevPrivateKey DRIPixmapPrivKey = &DRIPixmapPrivKey;
static RESTYPE DRIDrawablePrivResType;
@@ -185,11 +185,11 @@ DRIScreenInit(ScreenPtr pScreen)
pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
return FALSE;
}
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
pDRIPriv->directRenderingSupport = TRUE;
pDRIPriv->nrWindows = 0;
@@ -220,13 +220,6 @@ 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;
@@ -255,31 +248,13 @@ DRICloseScreen(ScreenPtr pScreen)
if (pDRIPriv && pDRIPriv->directRenderingSupport) {
xfree(pDRIPriv);
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, 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;
@@ -423,7 +398,8 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
}
/* save private off of preallocated index */
- pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv;
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
+ pDRIDrawablePriv);
}
}
@@ -456,7 +432,8 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
}
/* save private off of preallocated index */
- pPix->devPrivates[DRIPixmapPrivIndex].ptr = (pointer)pDRIDrawablePriv;
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
+ pDRIDrawablePriv);
}
}
#endif
@@ -583,9 +560,9 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
xfree(pDRIDrawablePriv);
if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
} else if (pDrawable->type == DRAWABLE_PIXMAP) {
- pPix->devPrivates[DRIPixmapPrivIndex].ptr = NULL;
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
}
--pDRIPriv->nrWindows;
diff --git a/hw/xquartz/xpr/dristruct.h b/hw/xquartz/xpr/dristruct.h
index 9a3d01c9b..19d78a973 100644
--- a/hw/xquartz/xpr/dristruct.h
+++ b/hw/xquartz/xpr/dristruct.h
@@ -40,15 +40,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#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_WINDOW(pWin) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
-#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \
- ((DRIPixmapPrivIndex < 0) ? \
- NULL : \
- ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIPixmapPrivIndex].ptr)))
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pPix)->devPrivates, DRIPixmapPrivKey))
typedef struct _DRIDrawablePrivRec
{
@@ -61,13 +57,12 @@ typedef struct _DRIDrawablePrivRec
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(pScreen) ((DRIScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey))
#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
- (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
+ dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
+ DRIScreenPrivKey))
typedef struct _DRIScreenPrivRec
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index dc7a73eab..e084ef90e 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -54,11 +54,10 @@ typedef struct {
miPointerSpriteFuncPtr spriteFuncs;
} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
+static DevPrivateKey darwinCursorScreenKey = &darwinCursorScreenKey;
-#define CURSOR_PRIV(pScreen) \
- ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
+ dixLookupPrivate(&pScreen->devPrivates, darwinCursorScreenKey))
static Bool
@@ -370,27 +369,18 @@ QuartzInitCursor(ScreenPtr pScreen)
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; */
- pScreen->devPrivates[darwinCursorScreenIndex].ptr = ScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, darwinCursorScreenKey, ScreenPriv);
/* override some screen procedures */
ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
pScreen->QueryBestSize = QuartzCursorQueryBestSize;
- PointPriv = (miPointerScreenPtr) pScreen->devPrivates[miPointerScreenIndex].ptr;
+ PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 2d97f2754..b9a33de90 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -339,7 +339,7 @@ xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
void
xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
{
- DeleteProperty(oldWin, xa_native_window_id());
+ DeleteProperty(serverClient, oldWin, xa_native_window_id());
xprSetNativeProperty(pFrame);
}
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 754666090..3ab324931 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -629,11 +629,11 @@ extern DWORD g_dwEvents;
#ifdef HAS_DEVWINDOWS
extern int g_fdMessageQueue;
#endif
-extern int g_iScreenPrivateIndex;
-extern int g_iCmapPrivateIndex;
-extern int g_iGCPrivateIndex;
-extern int g_iPixmapPrivateIndex;
-extern int g_iWindowPrivateIndex;
+extern DevPrivateKey g_iScreenPrivateKey;
+extern DevPrivateKey g_iCmapPrivateKey;
+extern DevPrivateKey g_iGCPrivateKey;
+extern DevPrivateKey g_iPixmapPrivateKey;
+extern DevPrivateKey g_iWindowPrivateKey;
extern unsigned long g_ulServerGeneration;
extern CARD32 g_c32LastInputEventTime;
extern DWORD g_dwEnginesSupported;
@@ -659,11 +659,11 @@ extern FARPROC g_fpTrackMouseEvent;
* Screen privates macros
*/
-#define winGetScreenPriv(pScreen) \
- ((winPrivScreenPtr) (pScreen)->devPrivates[g_iScreenPrivateIndex].ptr)
+#define winGetScreenPriv(pScreen) ((winPrivScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey))
#define winSetScreenPriv(pScreen,v) \
- ((pScreen)->devPrivates[g_iScreenPrivateIndex].ptr = (pointer) v)
+ dixSetPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey, v)
#define winScreenPriv(pScreen) \
winPrivScreenPtr pScreenPriv = winGetScreenPriv(pScreen)
@@ -673,11 +673,11 @@ extern FARPROC g_fpTrackMouseEvent;
* Colormap privates macros
*/
-#define winGetCmapPriv(pCmap) \
- ((winPrivCmapPtr) (pCmap)->devPrivates[g_iCmapPrivateIndex].ptr)
+#define winGetCmapPriv(pCmap) ((winPrivCmapPtr) \
+ dixLookupPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey))
#define winSetCmapPriv(pCmap,v) \
- ((pCmap)->devPrivates[g_iCmapPrivateIndex].ptr = (pointer) v)
+ dixSetPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey, v)
#define winCmapPriv(pCmap) \
winPrivCmapPtr pCmapPriv = winGetCmapPriv(pCmap)
@@ -687,11 +687,11 @@ extern FARPROC g_fpTrackMouseEvent;
* GC privates macros
*/
-#define winGetGCPriv(pGC) \
- ((winPrivGCPtr) (pGC)->devPrivates[g_iGCPrivateIndex].ptr)
+#define winGetGCPriv(pGC) ((winPrivGCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, g_iGCPrivateKey))
#define winSetGCPriv(pGC,v) \
- ((pGC)->devPrivates[g_iGCPrivateIndex].ptr = (pointer) v)
+ dixSetPrivate(&(pGC)->devPrivates, g_iGCPrivateKey, v)
#define winGCPriv(pGC) \
winPrivGCPtr pGCPriv = winGetGCPriv(pGC)
@@ -701,11 +701,11 @@ extern FARPROC g_fpTrackMouseEvent;
* Pixmap privates macros
*/
-#define winGetPixmapPriv(pPixmap) \
- ((winPrivPixmapPtr) (pPixmap)->devPrivates[g_iPixmapPrivateIndex].ptr)
+#define winGetPixmapPriv(pPixmap) ((winPrivPixmapPtr) \
+ dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey))
#define winSetPixmapPriv(pPixmap,v) \
- ((pPixmap)->devPrivates[g_iPixmapPrivateIndex].ptr = (pointer) v)
+ dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey, v)
#define winPixmapPriv(pPixmap) \
winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap)
@@ -715,11 +715,11 @@ extern FARPROC g_fpTrackMouseEvent;
* Window privates macros
*/
-#define winGetWindowPriv(pWin) \
- ((winPrivWinPtr) (pWin)->devPrivates[g_iWindowPrivateIndex].ptr)
+#define winGetWindowPriv(pWin) ((winPrivWinPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey))
#define winSetWindowPriv(pWin,v) \
- ((pWin)->devPrivates[g_iWindowPrivateIndex].ptr = (pointer) v)
+ dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey, v)
#define winWindowPriv(pWin) \
winPrivWinPtr pWinPriv = winGetWindowPriv(pWin)
diff --git a/hw/xwin/winallpriv.c b/hw/xwin/winallpriv.c
index f4decfb59..21ccd9b3b 100644
--- a/hw/xwin/winallpriv.c
+++ b/hw/xwin/winallpriv.c
@@ -57,12 +57,6 @@ winAllocatePrivates (ScreenPtr pScreen)
/* We need a new slot for our privates if the screen gen has changed */
if (g_ulServerGeneration != serverGeneration)
{
- /* Get an index that we can store our privates at */
- g_iScreenPrivateIndex = AllocateScreenPrivateIndex ();
- g_iGCPrivateIndex = AllocateGCPrivateIndex ();
- g_iPixmapPrivateIndex = AllocatePixmapPrivateIndex ();
- g_iWindowPrivateIndex = AllocateWindowPrivateIndex ();
-
g_ulServerGeneration = serverGeneration;
}
@@ -84,24 +78,21 @@ winAllocatePrivates (ScreenPtr pScreen)
winSetScreenPriv (pScreen, pScreenPriv);
/* Reserve GC memory for our privates */
- if (!AllocateGCPrivate (pScreen, g_iGCPrivateIndex,
- sizeof (winPrivGCRec)))
+ if (!dixRequestPrivate(g_iGCPrivateKey, sizeof (winPrivGCRec)))
{
ErrorF ("winAllocatePrivates - AllocateGCPrivate () failed\n");
return FALSE;
}
/* Reserve Pixmap memory for our privates */
- if (!AllocatePixmapPrivate (pScreen, g_iPixmapPrivateIndex,
- sizeof (winPrivPixmapRec)))
+ if (!dixRequestPrivate(g_iPixmapPrivateKey, sizeof (winPrivPixmapRec)))
{
ErrorF ("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
return FALSE;
}
/* Reserve Window memory for our privates */
- if (!AllocateWindowPrivate (pScreen, g_iWindowPrivateIndex,
- sizeof (winPrivWinRec)))
+ if (!dixRequestPrivate(g_iWindowPrivateKey, sizeof (winPrivWinRec)))
{
ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
return FALSE;
@@ -155,9 +146,6 @@ winAllocateCmapPrivates (ColormapPtr pCmap)
/* Get a new privates index when the server generation changes */
if (s_ulPrivateGeneration != serverGeneration)
{
- /* Get an index that we can store our privates at */
- g_iCmapPrivateIndex = AllocateColormapPrivateIndex (winInitCmapPrivates);
-
/* Save the new server generation */
s_ulPrivateGeneration = serverGeneration;
}
diff --git a/hw/xwin/winclipboardwrappers.c b/hw/xwin/winclipboardwrappers.c
index 825d3dc70..2cfe0ffce 100755
--- a/hw/xwin/winclipboardwrappers.c
+++ b/hw/xwin/winclipboardwrappers.c
@@ -431,7 +431,6 @@ winProcSetSelectionOwner (ClientPtr client)
* and we currently own the Win32 clipboard.
*/
if (None == stuff->window
- && g_iClipboardWindow != client->lastDrawableID
&& (None == s_iOwners[CLIP_OWN_PRIMARY]
|| g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
&& (None == s_iOwners[CLIP_OWN_CLIPBOARD]
diff --git a/hw/xwin/wincursor.c b/hw/xwin/wincursor.c
index c1e619bf8..021b8b82c 100644
--- a/hw/xwin/wincursor.c
+++ b/hw/xwin/wincursor.c
@@ -598,7 +598,8 @@ winInitCursor (ScreenPtr pScreen)
pScreenPriv->cursor.QueryBestSize = pScreen->QueryBestSize;
pScreen->QueryBestSize = winCursorQueryBestSize;
- pPointPriv = (miPointerScreenPtr) pScreen->devPrivates[miPointerScreenIndex].ptr;
+ pPointPriv = (miPointerScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
pScreenPriv->cursor.spriteFuncs = pPointPriv->spriteFuncs;
pPointPriv->spriteFuncs = &winSpriteFuncsRec;
diff --git a/hw/xwin/winfillsp.c b/hw/xwin/winfillsp.c
index 7e3966965..702f34f96 100644
--- a/hw/xwin/winfillsp.c
+++ b/hw/xwin/winfillsp.c
@@ -35,15 +35,6 @@
#include "win.h"
-/*
- * References to external symbols
- */
-
-extern int g_iPixmapPrivateIndex;
-extern int g_iGCPrivateIndex;
-extern int g_copyROP[];
-
-
extern void ROP16(HDC hdc, int rop);
#define TRANSLATE_COLOR(color) \
diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c
index af8190d3f..fddada39e 100644
--- a/hw/xwin/winglobals.c
+++ b/hw/xwin/winglobals.c
@@ -44,11 +44,11 @@ int g_iLastScreen = -1;
#ifdef HAS_DEVWINDOWS
int g_fdMessageQueue = WIN_FD_INVALID;
#endif
-int g_iScreenPrivateIndex = -1;
-int g_iCmapPrivateIndex = -1;
-int g_iGCPrivateIndex = -1;
-int g_iPixmapPrivateIndex = -1;
-int g_iWindowPrivateIndex = -1;
+DevPrivateKey g_iScreenPrivateKey = &g_iScreenPrivateKey;
+DevPrivateKey g_iCmapPrivateKey = &g_iCmapPrivateKey;
+DevPrivateKey g_iGCPrivateKey = &g_iGCPrivateKey;
+DevPrivateKey g_iPixmapPrivateKey = &g_iPixmapPrivateKey;
+DevPrivateKey g_iWindowPrivateKey = &g_iWindowPrivateKey;
unsigned long g_ulServerGeneration = 0;
Bool g_fInitializedDefaultScreens = FALSE;
DWORD g_dwEnginesSupported = 0;
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 0a7579b61..20ff9f7db 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -365,7 +365,7 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
ErrorF ("\thenght %08X\n", pWin->drawable.height);
ErrorF ("\tpScreen %08X\n", pWin->drawable.pScreen);
ErrorF ("\tserialNumber %08X\n", pWin->drawable.serialNumber);
- ErrorF ("g_iWindowPrivateIndex %d\n", g_iWindowPrivateIndex);
+ ErrorF ("g_iWindowPrivateKey %p\n", g_iWindowPrivateKey);
ErrorF ("pWinPriv %08X\n", pWinPriv);
ErrorF ("s_pScreenPriv %08X\n", s_pScreenPriv);
ErrorF ("s_pScreenInfo %08X\n", s_pScreenInfo);
diff --git a/hw/xwin/winpixmap.c b/hw/xwin/winpixmap.c
index 07020eee0..050c71a7f 100644
--- a/hw/xwin/winpixmap.c
+++ b/hw/xwin/winpixmap.c
@@ -36,13 +36,6 @@
/*
- * References to external symbols
- */
-
-extern int g_iPixmapPrivateIndex;
-
-
-/*
* Local prototypes
*/
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index a49f68f7e..9dc4c3da5 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -73,9 +73,6 @@ winMWExtWMProcs = {
* References to external symbols
*/
-extern winScreenInfo g_ScreenInfo[];
-extern miPointerScreenFuncRec g_winPointerCursorFuncs;
-extern int g_iScreenPrivateIndex;
extern Bool g_fSoftwareCursor;
diff --git a/hw/xwin/winsetsp.c b/hw/xwin/winsetsp.c
index 8a3faee93..f894d6cda 100644
--- a/hw/xwin/winsetsp.c
+++ b/hw/xwin/winsetsp.c
@@ -35,15 +35,6 @@
#include "win.h"
-/*
- * References to external symbols
- */
-
-extern int g_iPixmapPrivateIndex;
-extern int g_iGCPrivateIndex;
-extern int g_copyROP[];
-
-
/* See Porting Layer Definition - p. 55 */
void
winSetSpansNativeGDI (DrawablePtr pDrawable,
diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index 832e36d44..4b4cd3ded 100755
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -971,7 +971,7 @@ winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
WS_POPUP | WS_CLIPCHILDREN);
- DeleteProperty (oldWin, AtmWindowsWmNativeHwnd ());
+ DeleteProperty (serverClient, oldWin, AtmWindowsWmNativeHwnd ());
winMWExtWMSetNativeProperty (pFrame);
#if CYGMULTIWINDOW_DEBUG
#if 0
diff --git a/include/Makefile.am b/include/Makefile.am
index 96d98b526..0654b5788 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -11,6 +11,7 @@ sdk_HEADERS = \
cursor.h \
cursorstr.h \
dix.h \
+ dixaccess.h \
dixevents.h \
dixfont.h \
dixfontstr.h \
@@ -31,10 +32,12 @@ sdk_HEADERS = \
os.h \
pixmap.h \
pixmapstr.h \
+ privates.h \
property.h \
propertyst.h \
region.h \
regionstr.h \
+ registry.h \
resource.h \
rgb.h \
screenint.h \
diff --git a/include/colormapst.h b/include/colormapst.h
index c9d9514ad..f1fc8ebef 100644
--- a/include/colormapst.h
+++ b/include/colormapst.h
@@ -52,6 +52,7 @@ SOFTWARE.
#include "colormap.h"
#include "screenint.h"
+#include "privates.h"
/* Shared color -- the color is used by AllocColorPlanes */
typedef struct
@@ -126,7 +127,7 @@ typedef struct _ColormapRec
Entry *green;
Entry *blue;
pointer devPriv;
- DevUnion *devPrivates; /* dynamic devPrivates added after devPriv
+ PrivateRec *devPrivates; /* dynamic devPrivates added after devPriv
already existed - must keep devPriv */
} ColormapRec;
diff --git a/include/cursor.h b/include/cursor.h
index dc0810cd1..8635cf1a2 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -68,23 +68,7 @@ extern int FreeCursor(
pointer /*pCurs*/,
XID /*cid*/);
-/* Quartz support on Mac OS X pulls in the QuickDraw
- framework whose AllocCursor function conflicts here. */
-#ifdef __APPLE__
-#define AllocCursor Darwin_X_AllocCursor
-#endif
-extern CursorPtr AllocCursor(
- unsigned char* /*psrcbits*/,
- unsigned char* /*pmaskbits*/,
- CursorMetricPtr /*cm*/,
- unsigned /*foreRed*/,
- unsigned /*foreGreen*/,
- unsigned /*foreBlue*/,
- unsigned /*backRed*/,
- unsigned /*backGreen*/,
- unsigned /*backBlue*/);
-
-extern CursorPtr AllocCursorARGB(
+extern int AllocARGBCursor(
unsigned char* /*psrcbits*/,
unsigned char* /*pmaskbits*/,
CARD32* /*argb*/,
@@ -94,7 +78,10 @@ extern CursorPtr AllocCursorARGB(
unsigned /*foreBlue*/,
unsigned /*backRed*/,
unsigned /*backGreen*/,
- unsigned /*backBlue*/);
+ unsigned /*backBlue*/,
+ CursorPtr* /*ppCurs*/,
+ ClientPtr /*client*/,
+ XID /*cid*/);
extern int AllocGlyphCursor(
Font /*source*/,
@@ -108,7 +95,8 @@ extern int AllocGlyphCursor(
unsigned /*backGreen*/,
unsigned /*backBlue*/,
CursorPtr* /*ppCurs*/,
- ClientPtr /*client*/);
+ ClientPtr /*client*/,
+ XID /*cid*/);
extern CursorPtr CreateRootCursor(
char* /*pfilename*/,
diff --git a/include/cursorstr.h b/include/cursorstr.h
index b7beaa0c5..bca35969b 100644
--- a/include/cursorstr.h
+++ b/include/cursorstr.h
@@ -49,6 +49,7 @@ SOFTWARE.
#define CURSORSTRUCT_H
#include "cursor.h"
+#include "privates.h"
/*
* device-independent cursor storage
*/
@@ -63,7 +64,7 @@ typedef struct _CursorBits {
Bool emptyMask; /* all zeros mask */
unsigned short width, height, xhot, yhot; /* metrics */
int refcnt; /* can be shared */
- pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/
+ PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/
#ifdef ARGB_CURSOR
CARD32 *argb; /* full-color alpha blended */
#endif
@@ -74,7 +75,8 @@ typedef struct _Cursor {
unsigned short foreRed, foreGreen, foreBlue; /* device-independent color */
unsigned short backRed, backGreen, backBlue; /* device-independent color */
int refcnt;
- pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/
+ PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/
+ XID id;
#ifdef XFIXES
CARD32 serialNumber;
Atom name;
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 6a3af4445..068b55170 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -21,6 +21,9 @@
/* Default font path */
#undef COMPILEDDEFAULTFONTPATH
+/* Miscellaneous server configuration files path */
+#undef SERVER_MISC_CONFIG_PATH
+
/* Support Composite Extension */
#undef COMPOSITE
@@ -273,9 +276,6 @@
/* Internal define for Xinerama */
#undef PANORAMIX
-/* Support pixmap privates */
-#undef PIXPRIV
-
/* Overall prefix */
#undef PROJECTROOT
@@ -338,9 +338,15 @@
/* unaligned word accesses behave as expected */
#undef WORKING_UNALIGNED_INT
+/* Build X string registry */
+#undef XREGISTRY
+
/* Build X-ACE extension */
#undef XACE
+/* Build SELinux extension */
+#undef XSELINUX
+
/* Support XCMisc extension */
#undef XCMISC
@@ -497,9 +503,6 @@
/* Define to 1 if the DTrace Xserver provider probes should be built in */
#undef XSERVER_DTRACE
-/* Path to XErrorDB file */
-#undef XERRORDB_PATH
-
/* Define to 16-bit byteswap macro */
#undef bswap_16
diff --git a/include/dix.h b/include/dix.h
index c987548bf..8cfbbc4f6 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -81,29 +81,16 @@ SOFTWARE.
return(BadIDChoice);\
}
-#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
- if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
- (client->lastDrawableID != drawID))\
+#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, mode)\
{\
- int rc;\
- rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY,\
- DixWriteAccess);\
+ int rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY, mode);\
if (rc != Success)\
return rc;\
- rc = dixLookupGC(&(pGC), stuff->gc, client, DixReadAccess);\
+ rc = dixLookupGC(&(pGC), stuff->gc, client, DixUseAccess);\
if (rc != Success)\
return rc;\
if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\
return (BadMatch);\
- client->lastDrawable = pDraw;\
- client->lastDrawableID = drawID;\
- client->lastGC = pGC;\
- client->lastGCID = stuff->gc;\
- }\
- else\
- {\
- pGC = client->lastGC;\
- pDraw = client->lastDrawable;\
}\
if (pGC->serialNumber != pDraw->serialNumber)\
ValidateGC(pDraw, pGC);
@@ -158,8 +145,6 @@ extern void UpdateCurrentTime(void);
extern void UpdateCurrentTimeIf(void);
-extern void FlushClientCaches(XID /*id*/);
-
extern int dixDestroyPixmap(
pointer /*value*/,
XID /*pid*/);
@@ -227,17 +212,6 @@ extern int dixLookupClient(
ClientPtr client,
Mask access_mode);
-/*
- * These are deprecated compatibility functions and will be removed soon!
- * Please use the new dixLookup*() functions above.
- */
-extern WindowPtr SecurityLookupWindow(XID, ClientPtr, Mask);
-extern WindowPtr LookupWindow(XID, ClientPtr);
-extern pointer SecurityLookupDrawable(XID, ClientPtr, Mask);
-extern pointer LookupDrawable(XID, ClientPtr);
-extern ClientPtr LookupClient(XID, ClientPtr);
-/* end deprecated functions */
-
extern void NoopDDA(void);
extern int AlterSaveSetForClient(
@@ -510,14 +484,6 @@ void
ScreenRestructured (ScreenPtr pScreen);
#endif
-extern void ResetClientPrivates(void);
-
-extern int AllocateClientPrivateIndex(void);
-
-extern Bool AllocateClientPrivate(
- int /*index*/,
- unsigned /*amount*/);
-
extern int ffs(int i);
/*
@@ -615,12 +581,15 @@ extern CallbackListPtr SelectionCallback;
typedef enum {
SelectionSetOwner,
+ SelectionGetOwner,
+ SelectionConvertSelection,
SelectionWindowDestroy,
SelectionClientClose
} SelectionCallbackKind;
typedef struct {
struct _Selection *selection;
+ ClientPtr client;
SelectionCallbackKind kind;
} SelectionInfoRec;
@@ -630,4 +599,36 @@ typedef struct {
extern int xstrcasecmp(char *s1, char *s2);
#endif
+/*
+ * These are deprecated compatibility functions and will be removed soon!
+ * Please use the noted replacements instead.
+ */
+
+/* replaced by dixLookupWindow */
+extern WindowPtr SecurityLookupWindow(
+ XID id,
+ ClientPtr client,
+ Mask access_mode);
+
+/* replaced by dixLookupWindow */
+extern WindowPtr LookupWindow(
+ XID id,
+ ClientPtr client);
+
+/* replaced by dixLookupDrawable */
+extern pointer SecurityLookupDrawable(
+ XID id,
+ ClientPtr client,
+ Mask access_mode);
+
+/* replaced by dixLookupDrawable */
+extern pointer LookupDrawable(
+ XID id,
+ ClientPtr client);
+
+/* replaced by dixLookupClient */
+extern ClientPtr LookupClient(
+ XID id,
+ ClientPtr client);
+
#endif /* DIX_H */
diff --git a/include/dixaccess.h b/include/dixaccess.h
new file mode 100644
index 000000000..3c62ee354
--- /dev/null
+++ b/include/dixaccess.h
@@ -0,0 +1,53 @@
+/***********************************************************
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifndef DIX_ACCESS_H
+#define DIX_ACCESS_H
+
+/* These are the access modes that can be passed in the last parameter
+ * to several of the dix lookup functions. They were originally part
+ * of the Security extension, now used by XACE.
+ *
+ * You can or these values together to indicate multiple modes
+ * simultaneously.
+ */
+
+#define DixUnknownAccess 0 /* don't know intentions */
+#define DixReadAccess (1<<0) /* inspecting the object */
+#define DixWriteAccess (1<<1) /* changing the object */
+#define DixDestroyAccess (1<<2) /* destroying the object */
+#define DixCreateAccess (1<<3) /* creating the object */
+#define DixGetAttrAccess (1<<4) /* get object attributes */
+#define DixSetAttrAccess (1<<5) /* set object attributes */
+#define DixListPropAccess (1<<6) /* list properties of object */
+#define DixGetPropAccess (1<<7) /* get properties of object */
+#define DixSetPropAccess (1<<8) /* set properties of object */
+#define DixGetFocusAccess (1<<9) /* get focus of object */
+#define DixSetFocusAccess (1<<10) /* set focus of object */
+#define DixListAccess (1<<11) /* list objects */
+#define DixAddAccess (1<<12) /* add object */
+#define DixRemoveAccess (1<<13) /* remove object */
+#define DixHideAccess (1<<14) /* hide object */
+#define DixShowAccess (1<<15) /* show object */
+#define DixBlendAccess (1<<16) /* mix contents of objects */
+#define DixGrabAccess (1<<17) /* exclusive access to object */
+#define DixFreezeAccess (1<<18) /* freeze status of object */
+#define DixForceAccess (1<<19) /* force status of object */
+#define DixInstallAccess (1<<20) /* install object */
+#define DixUninstallAccess (1<<21) /* uninstall object */
+#define DixSendAccess (1<<22) /* send to object */
+#define DixReceiveAccess (1<<23) /* receive from object */
+#define DixUseAccess (1<<24) /* use object */
+#define DixManageAccess (1<<25) /* manage object */
+#define DixDebugAccess (1<<26) /* debug object */
+#define DixBellAccess (1<<27) /* audible sound */
+
+#endif /* DIX_ACCESS_H */
diff --git a/include/dixfont.h b/include/dixfont.h
index d6d13b40a..516d91b58 100644
--- a/include/dixfont.h
+++ b/include/dixfont.h
@@ -105,8 +105,10 @@ extern int SetFontPath(ClientPtr /*client*/,
extern int SetDefaultFontPath(char * /*path*/);
-extern unsigned char *GetFontPath(int * /*count*/,
- int * /*length*/);
+extern int GetFontPath(ClientPtr client,
+ int *count,
+ int *length,
+ unsigned char **result);
extern int LoadGlyphs(ClientPtr /*client*/,
FontPtr /*pfont*/,
diff --git a/include/dixgrabs.h b/include/dixgrabs.h
index 2d66d6ba1..f93e99957 100644
--- a/include/dixgrabs.h
+++ b/include/dixgrabs.h
@@ -50,6 +50,7 @@ extern Bool GrabMatchesSecond(
GrabPtr /* pSecondGrab */);
extern int AddPassiveGrabToList(
+ ClientPtr /* client */,
GrabPtr /* pGrab */);
extern Bool DeletePassiveGrabFromList(
diff --git a/include/dixstruct.h b/include/dixstruct.h
index bed31dc2a..cbeac48cb 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -29,6 +29,7 @@ SOFTWARE.
#include "cursor.h"
#include "gc.h"
#include "pixmap.h"
+#include "privates.h"
#include <X11/Xmd.h>
/*
@@ -101,10 +102,6 @@ typedef struct _Client {
int clientGone;
int noClientException; /* this client died or needs to be
* killed */
- DrawablePtr lastDrawable;
- Drawable lastDrawableID;
- GCPtr lastGC;
- GContext lastGCID;
SaveSetElt *saveSet;
int numSaved;
pointer screenPrivate[MAXSCREENS];
@@ -114,7 +111,7 @@ typedef struct _Client {
Bool big_requests; /* supports large requests */
int priority;
ClientState clientState;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
#ifdef XKB
unsigned short xkbClientFlags;
unsigned short mapNotifyMask;
diff --git a/include/extension.h b/include/extension.h
index 74975c50b..6e6081740 100644
--- a/include/extension.h
+++ b/include/extension.h
@@ -58,14 +58,6 @@ extern Bool EnableDisableExtension(char *name, Bool enable);
extern void EnableDisableExtensionError(char *name, Bool enable);
-extern void ResetExtensionPrivates(void);
-
-extern int AllocateExtensionPrivateIndex(void);
-
-extern Bool AllocateExtensionPrivate(
- int /*index*/,
- unsigned /*amount*/);
-
extern void InitExtensions(int argc, char **argv);
extern void InitVisualWrap(void);
diff --git a/include/extinit.h b/include/extinit.h
index e616b6d93..df9773caf 100644
--- a/include/extinit.h
+++ b/include/extinit.h
@@ -44,9 +44,4 @@ AssignTypeAndName (
char * /* name */
);
-DeviceIntPtr
-LookupDeviceIntRec (
- CARD8 /* id */
- );
-
#endif /* EXTINIT_H */
diff --git a/include/extnsionst.h b/include/extnsionst.h
index 28ae1d539..59acd0ef4 100644
--- a/include/extnsionst.h
+++ b/include/extnsionst.h
@@ -53,6 +53,7 @@ SOFTWARE.
#include "screenint.h"
#include "extension.h"
#include "gc.h"
+#include "privates.h"
typedef struct _ExtensionEntry {
int index;
@@ -69,7 +70,7 @@ typedef struct _ExtensionEntry {
pointer extPrivate;
unsigned short (* MinorOpcode)( /* called for errors */
ClientPtr /* client */);
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
} ExtensionEntry;
/*
@@ -107,9 +108,5 @@ extern Bool AddExtensionAlias(
extern ExtensionEntry *CheckExtension(const char *extname);
extern ExtensionEntry *GetExtensionEntry(int major);
-extern void DeclareExtensionSecurity(
- char * /*extname*/,
- Bool /*secure*/);
-
#endif /* EXTENSIONSTRUCT_H */
diff --git a/include/gc.h b/include/gc.h
index 3b7e38e02..bf4c268a8 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -115,7 +115,9 @@ extern GCPtr CreateGC(
DrawablePtr /*pDrawable*/,
BITS32 /*mask*/,
XID* /*pval*/,
- int* /*pStatus*/);
+ int* /*pStatus*/,
+ XID /*gcid*/,
+ ClientPtr /*client*/);
extern int CopyGC(
GCPtr/*pgcSrc*/,
diff --git a/include/gcstruct.h b/include/gcstruct.h
index 14f747836..8d9b05575 100644
--- a/include/gcstruct.h
+++ b/include/gcstruct.h
@@ -56,6 +56,7 @@ SOFTWARE.
#include "region.h"
#include "pixmap.h"
#include "screenint.h"
+#include "privates.h"
#include <X11/Xprotostr.h>
/*
@@ -308,7 +309,7 @@ typedef struct _GC {
unsigned long serialNumber;
GCFuncs *funcs;
GCOps *ops;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
/*
* The following were moved here from private storage to allow device-
* independent access to them from screen wrappers.
diff --git a/include/input.h b/include/input.h
index b399d3ad1..ca67cfac5 100644
--- a/include/input.h
+++ b/include/input.h
@@ -158,10 +158,6 @@ typedef struct {
unsigned char id;
} LedCtrl;
-extern int AllocateDevicePrivateIndex(void);
-extern Bool AllocateDevicePrivate(DeviceIntPtr device, int index);
-extern void ResetDevicePrivateIndex(void);
-
extern KeybdCtrl defaultKeyboardControl;
extern PtrCtrl defaultPointerControl;
@@ -201,12 +197,11 @@ extern void RegisterPointerDevice(
extern void RegisterKeyboardDevice(
DeviceIntPtr /*device*/);
-extern DevicePtr LookupKeyboardDevice(void);
-
-extern DevicePtr LookupPointerDevice(void);
-
-extern DevicePtr LookupDevice(
- int /* id */);
+extern int dixLookupDevice(
+ DeviceIntPtr * /* dev */,
+ int /* id */,
+ ClientPtr /* client */,
+ Mask /* access_mode */);
extern void QueryMinMaxKeyCodes(
KeyCode* /*minCode*/,
@@ -440,9 +435,6 @@ extern int GetMotionHistory(
extern void SwitchCoreKeyboard(DeviceIntPtr pDev);
extern void SwitchCorePointer(DeviceIntPtr pDev);
-extern DeviceIntPtr LookupDeviceIntRec(
- CARD8 deviceid);
-
/* Implemented by the DDX. */
extern int NewInputDeviceRequest(
InputOption *options,
diff --git a/include/inputstr.h b/include/inputstr.h
index d0cc85811..6a1d5c9d7 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -52,6 +52,7 @@ SOFTWARE.
#include "input.h"
#include "window.h"
#include "dixstruct.h"
+#include "privates.h"
#define BitIsOn(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
@@ -62,7 +63,7 @@ SOFTWARE.
#define EMASKSIZE MAX_DEVICES
-extern int CoreDevicePrivatesIndex;
+extern DevPrivateKey CoreDevicePrivateKey;
/* Kludge: OtherClients and InputClients must be compatible, see code */
@@ -328,7 +329,7 @@ typedef struct _DeviceIntRec {
void *pad0;
#endif
char *config_info; /* used by the hotplug layer */
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
int nPrivates;
DeviceUnwrapProc unwrapProc;
} DeviceIntRec;
diff --git a/include/miscstruct.h b/include/miscstruct.h
index d240f1b28..409b102c0 100644
--- a/include/miscstruct.h
+++ b/include/miscstruct.h
@@ -50,7 +50,6 @@ SOFTWARE.
#include "misc.h"
#include <X11/Xprotostr.h>
-#include "gc.h"
#include <pixman.h>
typedef xPoint DDXPointRec;
@@ -61,17 +60,7 @@ typedef union _DevUnion {
pointer ptr;
long val;
unsigned long uval;
- RegionPtr (*fptr)(
- DrawablePtr /* pSrcDrawable */,
- DrawablePtr /* pDstDrawable */,
- GCPtr /* pGC */,
- int /* srcx */,
- int /* srcy */,
- int /* width */,
- int /* height */,
- int /* dstx */,
- int /* dsty */,
- unsigned long /* bitPlane */);
+ pointer (*fptr)(void);
} DevUnion;
#endif /* MISCSTRUCT_H */
diff --git a/include/os.h b/include/os.h
index c53a9ea8b..4be6b8010 100644
--- a/include/os.h
+++ b/include/os.h
@@ -154,7 +154,7 @@ extern void AddEnabledDevice(int /*fd*/);
extern void RemoveEnabledDevice(int /*fd*/);
-extern void OnlyListenToOneClient(ClientPtr /*client*/);
+extern int OnlyListenToOneClient(ClientPtr /*client*/);
extern void ListenToAllClients(void);
diff --git a/include/pixmapstr.h b/include/pixmapstr.h
index dc03cf202..cc5a8d8de 100644
--- a/include/pixmapstr.h
+++ b/include/pixmapstr.h
@@ -47,27 +47,17 @@ SOFTWARE.
#ifndef PIXMAPSTRUCT_H
#define PIXMAPSTRUCT_H
-#include <X11/Xarch.h>
#include "pixmap.h"
#include "screenint.h"
#include "regionstr.h"
-
-/*
- * The padN members are unfortunate ABI BC. See fdo bug #6924.
- */
+#include "privates.h"
typedef struct _Drawable {
unsigned char type; /* DRAWABLE_<type> */
unsigned char class; /* specific to type */
unsigned char depth;
unsigned char bitsPerPixel;
-#if defined(_XSERVER64)
- XID pad0;
-#endif
XID id; /* resource id */
-#if defined(_XSERVER64)
- XID pad1;
-#endif
short x; /* window: screen absolute, pixmap: 0 */
short y; /* window: screen absolute, pixmap: 0 */
unsigned short width;
@@ -82,10 +72,10 @@ typedef struct _Drawable {
typedef struct _Pixmap {
DrawableRec drawable;
+ PrivateRec *devPrivates;
int refcnt;
int devKind;
DevUnion devPrivate;
- DevUnion *devPrivates; /* real devPrivates like gcs & windows */
#ifdef COMPOSITE
short screen_x;
short screen_y;
diff --git a/include/privates.h b/include/privates.h
new file mode 100644
index 000000000..8d59b728f
--- /dev/null
+++ b/include/privates.h
@@ -0,0 +1,157 @@
+/***********************************************************
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifndef PRIVATES_H
+#define PRIVATES_H 1
+
+#include "dix.h"
+#include "resource.h"
+
+/*****************************************************************
+ * STUFF FOR PRIVATES
+ *****************************************************************/
+
+typedef void *DevPrivateKey;
+
+typedef struct _Private {
+ DevPrivateKey key;
+ pointer value;
+ struct _Private *next;
+} PrivateRec;
+
+/*
+ * Request pre-allocated private space for your driver/module.
+ * Calling this is not necessary if only a pointer by itself is needed.
+ */
+extern int
+dixRequestPrivate(const DevPrivateKey key, unsigned size);
+
+/*
+ * Allocates a new private and attaches it to an existing object.
+ */
+extern pointer *
+dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key);
+
+/*
+ * Look up a private pointer.
+ */
+static _X_INLINE pointer
+dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
+{
+ PrivateRec *rec = *privates;
+ pointer *ptr;
+
+ while (rec) {
+ if (rec->key == key)
+ return rec->value;
+ rec = rec->next;
+ }
+
+ ptr = dixAllocatePrivate(privates, key);
+ return ptr ? *ptr : NULL;
+}
+
+/*
+ * Look up the address of a private pointer.
+ */
+static _X_INLINE pointer *
+dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
+{
+ PrivateRec *rec = *privates;
+
+ while (rec) {
+ if (rec->key == key)
+ return &rec->value;
+ rec = rec->next;
+ }
+
+ return dixAllocatePrivate(privates, key);
+}
+
+/*
+ * Set a private pointer.
+ */
+static _X_INLINE int
+dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
+{
+ PrivateRec *rec;
+
+ top:
+ rec = *privates;
+ while (rec) {
+ if (rec->key == key) {
+ rec->value = val;
+ return TRUE;
+ }
+ rec = rec->next;
+ }
+
+ if (!dixAllocatePrivate(privates, key))
+ return FALSE;
+ goto top;
+}
+
+/*
+ * Register callbacks to be called on private allocation/freeing.
+ * The calldata argument to the callbacks is a PrivateCallbackPtr.
+ */
+typedef struct _PrivateCallback {
+ DevPrivateKey key; /* private registration key */
+ pointer *value; /* address of private pointer */
+} PrivateCallbackRec;
+
+extern int
+dixRegisterPrivateInitFunc(const DevPrivateKey key,
+ CallbackProcPtr callback, pointer userdata);
+
+extern int
+dixRegisterPrivateDeleteFunc(const DevPrivateKey key,
+ CallbackProcPtr callback, pointer userdata);
+
+/*
+ * Frees private data.
+ */
+extern void
+dixFreePrivates(PrivateRec *privates);
+
+/*
+ * Resets the subsystem, called from the main loop.
+ */
+extern int
+dixResetPrivates(void);
+
+/*
+ * These next two functions are necessary because the position of
+ * the devPrivates field varies by structure and calling code might
+ * only know the resource type, not the structure definition.
+ */
+
+/*
+ * Looks up the offset where the devPrivates field is located.
+ * Returns -1 if no offset has been registered for the resource type.
+ */
+extern int
+dixLookupPrivateOffset(RESTYPE type);
+
+/*
+ * Specifies the offset where the devPrivates field is located.
+ * A negative value indicates no devPrivates field is available.
+ */
+extern int
+dixRegisterPrivateOffset(RESTYPE type, int offset);
+
+/*
+ * Convenience macro for adding an offset to an object pointer
+ * when making a call to one of the devPrivates functions
+ */
+#define DEVPRIV_AT(ptr, offset) ((PrivateRec **)((char *)ptr + offset))
+
+#endif /* PRIVATES_H */
diff --git a/include/property.h b/include/property.h
index 8b6dc0912..ba7d226cd 100644
--- a/include/property.h
+++ b/include/property.h
@@ -52,6 +52,17 @@ SOFTWARE.
typedef struct _Property *PropertyPtr;
+extern int dixChangeWindowProperty(
+ ClientPtr /*pClient*/,
+ WindowPtr /*pWin*/,
+ Atom /*property*/,
+ Atom /*type*/,
+ int /*format*/,
+ int /*mode*/,
+ unsigned long /*len*/,
+ pointer /*value*/,
+ Bool /*sendevent*/);
+
extern int ChangeWindowProperty(
WindowPtr /*pWin*/,
Atom /*property*/,
@@ -63,6 +74,7 @@ extern int ChangeWindowProperty(
Bool /*sendevent*/);
extern int DeleteProperty(
+ ClientPtr /*client*/,
WindowPtr /*pWin*/,
Atom /*propName*/);
diff --git a/include/propertyst.h b/include/propertyst.h
index 6add81d9a..fd1148eb7 100644
--- a/include/propertyst.h
+++ b/include/propertyst.h
@@ -49,6 +49,7 @@ SOFTWARE.
#define PROPERTYSTRUCT_H
#include "misc.h"
#include "property.h"
+#include "privates.h"
/*
* PROPERTY -- property element
*/
@@ -60,6 +61,7 @@ typedef struct _Property {
short format; /* format of data for swapping - 8,16,32 */
long size; /* size of data in (format/8) bytes */
pointer data; /* private to client */
+ PrivateRec *devPrivates;
} PropertyRec;
#endif /* PROPERTYSTRUCT_H */
diff --git a/include/registry.h b/include/registry.h
new file mode 100644
index 000000000..edd6ef9a7
--- /dev/null
+++ b/include/registry.h
@@ -0,0 +1,64 @@
+/***********************************************************
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+#ifndef DIX_REGISTRY_H
+#define DIX_REGISTRY_H
+
+#ifdef XREGISTRY
+
+#include "resource.h"
+#include "extnsionst.h"
+
+/* Internal string registry - for auditing, debugging, security, etc. */
+
+/*
+ * Registration functions. The name string is not copied, so it must
+ * not be a stack variable.
+ */
+void RegisterResourceName(RESTYPE type, char *name);
+void RegisterExtensionNames(ExtensionEntry *ext);
+
+/*
+ * Lookup functions. The returned string must not be modified or freed.
+ */
+const char *LookupMajorName(int major);
+const char *LookupRequestName(int major, int minor);
+const char *LookupEventName(int event);
+const char *LookupErrorName(int error);
+const char *LookupResourceName(RESTYPE rtype);
+
+/*
+ * Result returned from any unsuccessful lookup
+ */
+#define XREGISTRY_UNKNOWN "<unknown>"
+
+/*
+ * Setup and teardown
+ */
+void dixResetRegistry(void);
+
+#else /* XREGISTRY */
+
+/* Define calls away when the registry is not being built. */
+
+#define RegisterResourceName(a, b) { ; }
+#define RegisterExtensionNames(a) { ; }
+
+#define LookupMajorName(a) XREGISTRY_UNKNOWN
+#define LookupRequestName(a, b) XREGISTRY_UNKNOWN
+#define LookupEventName(a) XREGISTRY_UNKNOWN
+#define LookupErrorName(a) XREGISTRY_UNKNOWN
+#define LookupResourceName(a) XREGISTRY_UNKNOWN
+
+#define dixResetRegistry() { ; }
+
+#endif /* XREGISTRY */
+#endif /* DIX_REGISTRY_H */
diff --git a/include/resource.h b/include/resource.h
index 6c0d5dc7f..b8105d45a 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -48,6 +48,7 @@ SOFTWARE.
#ifndef RESOURCE_H
#define RESOURCE_H 1
#include "misc.h"
+#include "dixaccess.h"
/*****************************************************************
* STUFF FOR RESOURCES
@@ -71,9 +72,9 @@ typedef unsigned long RESTYPE;
/* types for Resource routines */
-#define RT_WINDOW ((RESTYPE)1|RC_CACHED|RC_DRAWABLE)
-#define RT_PIXMAP ((RESTYPE)2|RC_CACHED|RC_DRAWABLE)
-#define RT_GC ((RESTYPE)3|RC_CACHED)
+#define RT_WINDOW ((RESTYPE)1|RC_DRAWABLE)
+#define RT_PIXMAP ((RESTYPE)2|RC_DRAWABLE)
+#define RT_GC ((RESTYPE)3)
#undef RT_FONT
#undef RT_CURSOR
#define RT_FONT ((RESTYPE)4)
@@ -120,6 +121,19 @@ typedef unsigned long RESTYPE;
#define BAD_RESOURCE 0xe0000000
+/* Resource state callback */
+extern CallbackListPtr ResourceStateCallback;
+
+typedef enum {ResourceStateAdding,
+ ResourceStateFreeing} ResourceState;
+
+typedef struct {
+ ResourceState state;
+ XID id;
+ RESTYPE type;
+ pointer value;
+} ResourceStateInfoRec;
+
typedef int (*DeleteType)(
pointer /*value*/,
XID /*id*/);
@@ -198,46 +212,18 @@ extern Bool LegalNewID(
XID /*id*/,
ClientPtr /*client*/);
-extern pointer LookupIDByType(
- XID /*id*/,
- RESTYPE /*rtype*/);
-
-extern pointer LookupIDByClass(
- XID /*id*/,
- RESTYPE /*classes*/);
-
extern pointer LookupClientResourceComplex(
ClientPtr client,
RESTYPE type,
FindComplexResType func,
pointer cdata);
-/* These are the access modes that can be passed in the last parameter
- * to SecurityLookupIDByType/Class. The Security extension doesn't
- * currently make much use of these; they're mainly provided as an
- * example of what you might need for discretionary access control.
- * You can or these values together to indicate multiple modes
- * simultaneously.
- */
-
-#define DixUnknownAccess 0 /* don't know intentions */
-#define DixReadAccess (1<<0) /* inspecting the object */
-#define DixWriteAccess (1<<1) /* changing the object */
-#define DixReadWriteAccess (DixReadAccess|DixWriteAccess)
-#define DixDestroyAccess (1<<2) /* destroying the object */
-
-extern pointer SecurityLookupIDByType(
- ClientPtr /*client*/,
- XID /*id*/,
- RESTYPE /*rtype*/,
- Mask /*access_mode*/);
-
-extern pointer SecurityLookupIDByClass(
- ClientPtr /*client*/,
- XID /*id*/,
- RESTYPE /*classes*/,
- Mask /*access_mode*/);
-
+extern int dixLookupResource(
+ pointer *result,
+ XID id,
+ RESTYPE rtype,
+ ClientPtr client,
+ Mask access_mode);
extern void GetXIDRange(
int /*client*/,
@@ -253,10 +239,34 @@ extern unsigned int GetXIDList(
extern RESTYPE lastResourceType;
extern RESTYPE TypeMask;
-#ifdef XResExtension
-extern Atom *ResourceNames;
-void RegisterResourceName(RESTYPE type, char* name);
-#endif
+/*
+ * These are deprecated compatibility functions and will be removed soon!
+ * Please use the noted replacements instead.
+ */
+
+/* replaced by dixLookupResource */
+extern pointer SecurityLookupIDByType(
+ ClientPtr client,
+ XID id,
+ RESTYPE rtype,
+ Mask access_mode);
+
+/* replaced by dixLookupResource */
+extern pointer SecurityLookupIDByClass(
+ ClientPtr client,
+ XID id,
+ RESTYPE classes,
+ Mask access_mode);
+
+/* replaced by dixLookupResource */
+extern pointer LookupIDByType(
+ XID id,
+ RESTYPE rtype);
+
+/* replaced by dixLookupResource */
+extern pointer LookupIDByClass(
+ XID id,
+ RESTYPE classes);
#endif /* RESOURCE_H */
diff --git a/include/screenint.h b/include/screenint.h
index 1f1434a84..6d074a375 100644
--- a/include/screenint.h
+++ b/include/screenint.h
@@ -55,28 +55,6 @@ typedef struct _Visual *VisualPtr;
typedef struct _Depth *DepthPtr;
typedef struct _Screen *ScreenPtr;
-extern void ResetScreenPrivates(void);
-
-extern int AllocateScreenPrivateIndex(void);
-
-extern void ResetWindowPrivates(void);
-
-extern int AllocateWindowPrivateIndex(void);
-
-extern Bool AllocateWindowPrivate(
- ScreenPtr /* pScreen */,
- int /* index */,
- unsigned /* amount */);
-
-extern void ResetGCPrivates(void);
-
-extern int AllocateGCPrivateIndex(void);
-
-extern Bool AllocateGCPrivate(
- ScreenPtr /* pScreen */,
- int /* index */,
- unsigned /* amount */);
-
extern int AddScreen(
Bool (* /*pfnInit*/)(
int /*index*/,
@@ -86,22 +64,6 @@ extern int AddScreen(
int /*argc*/,
char** /*argv*/);
-extern void ResetPixmapPrivates(void);
-
-extern int AllocatePixmapPrivateIndex(void);
-
-extern Bool AllocatePixmapPrivate(
- ScreenPtr /* pScreen */,
- int /* index */,
- unsigned /* amount */);
-
-extern void ResetColormapPrivates(void);
-
-
typedef struct _ColormapRec *ColormapPtr;
-typedef int (*InitCmapPrivFunc)(ColormapPtr, int);
-
-extern int AllocateColormapPrivateIndex(
- InitCmapPrivFunc /* initPrivFunc */);
#endif /* SCREENINT_H */
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index bad0e51a9..3b2cf9f81 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -56,6 +56,7 @@ SOFTWARE.
#include "validate.h"
#include <X11/Xproto.h>
#include "dix.h"
+#include "privates.h"
typedef struct _PixmapFormat {
unsigned char depth;
@@ -457,12 +458,6 @@ typedef struct _Screen {
pointer devPrivate;
short numVisuals;
VisualPtr visuals;
- int WindowPrivateLen;
- unsigned *WindowPrivateSizes;
- unsigned totalWindowSize;
- int GCPrivateLen;
- unsigned *GCPrivateSizes;
- unsigned totalGCSize;
/* Random screen procedures */
@@ -554,7 +549,7 @@ typedef struct _Screen {
pointer wakeupData;
/* anybody can get a piece of this array */
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
CreateScreenResourcesProcPtr CreateScreenResources;
ModifyPixmapHeaderProcPtr ModifyPixmapHeader;
@@ -566,8 +561,6 @@ typedef struct _Screen {
PixmapPtr pScratchPixmap; /* scratch pixmap "pool" */
- int PixmapPrivateLen;
- unsigned int *PixmapPrivateSizes;
unsigned int totalPixmapSize;
MarkWindowProcPtr MarkWindow;
diff --git a/include/selection.h b/include/selection.h
index fbe7cfca6..859b6a3b5 100644
--- a/include/selection.h
+++ b/include/selection.h
@@ -50,6 +50,7 @@ SOFTWARE.
******************************************************************/
#include "dixstruct.h"
+#include "privates.h"
/*
*
* Selection data structures
@@ -61,6 +62,9 @@ typedef struct _Selection {
Window window;
WindowPtr pWin;
ClientPtr client;
+ ClientPtr alt_client; /* support for redirection */
+ Window alt_window; /* support for redirection */
+ PrivateRec *devPrivates;
} Selection;
#endif /* SELECTION_H */
diff --git a/include/window.h b/include/window.h
index 58e2c49b5..52b3982e3 100644
--- a/include/window.h
+++ b/include/window.h
@@ -83,9 +83,6 @@ extern int WalkTree(
VisitWindowProcPtr /*func*/,
pointer /*data*/);
-extern WindowPtr AllocateWindow(
- ScreenPtr /*pScreen*/);
-
extern Bool CreateRootWindow(
ScreenPtr /*pScreen*/);
@@ -119,7 +116,7 @@ extern int DeleteWindow(
pointer /*pWin*/,
XID /*wid*/);
-extern void DestroySubwindows(
+extern int DestroySubwindows(
WindowPtr /*pWin*/,
ClientPtr /*client*/);
@@ -207,9 +204,14 @@ extern RegionPtr NotClippedByChildren(
extern void SendVisibilityNotify(
WindowPtr /*pWin*/);
-extern void SaveScreens(
- int /*on*/,
- int /*mode*/);
+extern int dixSaveScreens(
+ ClientPtr client,
+ int on,
+ int mode);
+
+extern int SaveScreens(
+ int on,
+ int mode);
extern WindowPtr FindWindowWithOptional(
WindowPtr /*w*/);
diff --git a/include/windowstr.h b/include/windowstr.h
index 6d874ae9e..4359481cd 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -55,6 +55,7 @@ SOFTWARE.
#include "property.h"
#include "resource.h" /* for ROOT_WINDOW_ID_BASE */
#include "dix.h"
+#include "privates.h"
#include "miscstruct.h"
#include <X11/Xprotostr.h>
#include "opaque.h"
@@ -123,6 +124,7 @@ typedef struct _WindowOpt {
typedef struct _Window {
DrawableRec drawable;
+ PrivateRec *devPrivates;
WindowPtr parent; /* ancestor chain */
WindowPtr nextSib; /* next lower sibling */
WindowPtr prevSib; /* next higher sibling */
@@ -159,7 +161,6 @@ typedef struct _Window {
#ifdef COMPOSITE
unsigned redirectDraw:2; /* rendering is redirected from here */
#endif
- DevUnion *devPrivates;
} WindowRec;
/*
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 167dbec59..6425e37ae 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -268,8 +268,8 @@ typedef struct
device->public.realInputProc = oldprocs->realInputProc; \
device->unwrapProc = oldprocs->unwrapProc;
-extern int xkbDevicePrivateIndex;
-#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr) (dev)->devPrivates[xkbDevicePrivateIndex].ptr)
+extern DevPrivateKey xkbDevicePrivateKey;
+#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr)dixLookupPrivate(&(dev)->devPrivates, xkbDevicePrivateKey))
extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer);
@@ -287,6 +287,7 @@ extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer);
extern int XkbReqCode;
extern int XkbEventBase;
extern int XkbDisableLockActions;
+extern int XkbKeyboardErrorCode;
extern char * XkbBaseDirectory;
extern char * XkbBinDirectory;
extern char * XkbInitialMap;
@@ -378,29 +379,44 @@ extern void XkbFreeNames(
Bool /* freeMap */
);
-extern DeviceIntPtr _XkbLookupAnyDevice(
- int /* id */,
- int * /* why_rtrn */
+extern int _XkbLookupAnyDevice(
+ DeviceIntPtr *pDev,
+ int id,
+ ClientPtr client,
+ Mask access_mode,
+ int *xkb_err
);
-extern DeviceIntPtr _XkbLookupKeyboard(
- int /* id */,
- int * /* why_rtrn */
+extern int _XkbLookupKeyboard(
+ DeviceIntPtr *pDev,
+ int id,
+ ClientPtr client,
+ Mask access_mode,
+ int *xkb_err
);
-extern DeviceIntPtr _XkbLookupBellDevice(
- int /* id */,
- int * /* why_rtrn */
+extern int _XkbLookupBellDevice(
+ DeviceIntPtr *pDev,
+ int id,
+ ClientPtr client,
+ Mask access_mode,
+ int *xkb_err
);
-extern DeviceIntPtr _XkbLookupLedDevice(
- int /* id */,
- int * /* why_rtrn */
+extern int _XkbLookupLedDevice(
+ DeviceIntPtr *pDev,
+ int id,
+ ClientPtr client,
+ Mask access_mode,
+ int *xkb_err
);
-extern DeviceIntPtr _XkbLookupButtonDevice(
- int /* id */,
- int * /* why_rtrn */
+extern int _XkbLookupButtonDevice(
+ DeviceIntPtr *pDev,
+ int id,
+ ClientPtr client,
+ Mask access_mode,
+ int *xkb_err
);
extern XkbDescPtr XkbAllocKeyboard(
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 8e52ae106..b91ea9260 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -57,9 +57,6 @@
/* Solaris 8 or later? */
#undef __SOL8__
-/* Whether to use pixmap privates */
-#undef PIXPRIV
-
/* Define to 1 if you have the `walkcontext' function (used on Solaris for
xorg_backtrace in hw/xfree86/common/xf86Events.c */
#undef HAVE_WALKCONTEXT
diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in
index f38213117..dc6f1b31f 100644
--- a/include/xorg-server.h.in
+++ b/include/xorg-server.h.in
@@ -64,9 +64,6 @@
/* Internal define for Xinerama */
#undef PANORAMIX
-/* Support pixmap privates */
-#undef PIXPRIV
-
/* Support RANDR extension */
#undef RANDR
diff --git a/mfb/mfb.h b/mfb/mfb.h
index c24b54024..36f111380 100644
--- a/mfb/mfb.h
+++ b/mfb/mfb.h
@@ -58,6 +58,7 @@ SOFTWARE.
#include "region.h"
#include "gc.h"
#include "colormap.h"
+#include "privates.h"
#include "miscstruct.h"
#include "mibstore.h"
@@ -698,7 +699,7 @@ extern Bool mfbCloseScreen(
extern Bool mfbAllocatePrivates(
ScreenPtr /*pScreen*/,
- int * /*pGCIndex*/
+ DevPrivateKey * /*pGCKey*/
);
extern Bool mfbScreenInit(
@@ -883,12 +884,9 @@ typedef struct {
typedef mfbPrivGC *mfbPrivGCPtr;
#endif
-/* XXX these should be static, but it breaks the ABI */
-extern int mfbGCPrivateIndex; /* index into GC private array */
-extern int mfbGetGCPrivateIndex(void);
+extern DevPrivateKey mfbGetGCPrivateKey(void);
#ifdef PIXMAP_PER_WINDOW
-extern int frameWindowPrivateIndex; /* index into Window private array */
-extern int frameGetWindowPrivateIndex(void);
+extern DevPrivateKey frameGetWindowPrivateKey(void);
#endif
#ifndef MFB_PROTOTYPES_ONLY
diff --git a/mfb/mfbbitblt.c b/mfb/mfbbitblt.c
index 153cf6ac6..344c655ee 100644
--- a/mfb/mfbbitblt.c
+++ b/mfb/mfbbitblt.c
@@ -397,8 +397,7 @@ int dstx, dsty;
* must register a function for n-to-1 copy operations
*/
-static unsigned long copyPlaneGeneration;
-static int copyPlaneScreenIndex = -1;
+static DevPrivateKey copyPlaneScreenKey = &copyPlaneScreenKey;
Bool
mfbRegisterCopyPlaneProc (pScreen, proc)
@@ -415,14 +414,7 @@ mfbRegisterCopyPlaneProc (pScreen, proc)
int /* dsty */,
unsigned long /* bitPlane */);
{
- if (copyPlaneGeneration != serverGeneration)
- {
- copyPlaneScreenIndex = AllocateScreenPrivateIndex();
- if (copyPlaneScreenIndex < 0)
- return FALSE;
- copyPlaneGeneration = serverGeneration;
- }
- pScreen->devPrivates[copyPlaneScreenIndex].fptr = proc;
+ dixSetPrivate(&pScreen->devPrivates, copyPlaneScreenKey, proc);
return TRUE;
}
@@ -467,10 +459,8 @@ unsigned long plane;
if (pSrcDrawable->depth != 1)
{
- if (copyPlaneScreenIndex >= 0 &&
- (copyPlane =
- pSrcDrawable->pScreen->devPrivates[copyPlaneScreenIndex].fptr)
- )
+ if ((copyPlane = dixLookupPrivate(&pSrcDrawable->pScreen->devPrivates,
+ copyPlaneScreenKey)))
{
return (*copyPlane) (pSrcDrawable, pDstDrawable,
pGC, srcx, srcy, width, height, dstx, dsty, plane);
diff --git a/mfb/mfbfillarc.c b/mfb/mfbfillarc.c
index 30ec00dc3..cbf47a0eb 100644
--- a/mfb/mfbfillarc.c
+++ b/mfb/mfbfillarc.c
@@ -289,7 +289,8 @@ mfbPolyFillArcSolid(pDraw, pGC, narcs, parcs)
RegionPtr cclip;
int rop;
- priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
rop = priv->rop;
if ((rop == RROP_NOP) || !(pGC->planemask & 1))
return;
diff --git a/mfb/mfbfillrct.c b/mfb/mfbfillrct.c
index 594c7f01b..a0b3d6716 100644
--- a/mfb/mfbfillrct.c
+++ b/mfb/mfbfillrct.c
@@ -96,7 +96,8 @@ mfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
if (!(pGC->planemask & 1))
return;
- priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
alu = priv->ropFillArea;
pfn = priv->FillArea;
ppix = pGC->pRotatedPixmap;
diff --git a/mfb/mfbfillsp.c b/mfb/mfbfillsp.c
index f83ca6a54..c073535df 100644
--- a/mfb/mfbfillsp.c
+++ b/mfb/mfbfillsp.c
@@ -624,7 +624,8 @@ mfbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
if (pGC->fillStyle == FillTiled)
rop = pGC->alu;
else
- rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->ropOpStip;
+ rop = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->ropOpStip;
flip = 0;
switch(rop)
@@ -769,7 +770,8 @@ mfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
{
pTile = pGC->stipple;
tlwidth = pTile->devKind / PGSZB;
- rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->ropOpStip;
+ rop = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->ropOpStip;
}
xSrc = pDrawable->x;
@@ -926,7 +928,8 @@ mfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
ppt, pwidth, fSorted);
pTile = pGC->stipple;
- rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
+ rop = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop;
tlwidth = pTile->devKind / PGSZB;
xSrc = pDrawable->x;
ySrc = pDrawable->y;
diff --git a/mfb/mfbgc.c b/mfb/mfbgc.c
index c60e97676..7492d7c04 100644
--- a/mfb/mfbgc.c
+++ b/mfb/mfbgc.c
@@ -381,7 +381,8 @@ matchCommon (
FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
FONTMINBOUNDS(pGC->font,characterWidth) < 0)
return 0;
- priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
for (i = 0; i < numberCommonOps; i++) {
cop = &mfbCommonOps[i];
if ((pGC->fgPixel & 1) != cop->fg)
@@ -420,7 +421,8 @@ mfbCreateGC(pGC)
/* mfb wants to translate before scan convesion */
pGC->miTranslate = 1;
- pPriv = (mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr);
+ pPriv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
pPriv->rop = mfbReduceRop(pGC->alu, pGC->fgPixel);
pGC->fExpose = TRUE;
pGC->pRotatedPixmap = NullPixmap;
@@ -508,8 +510,8 @@ mfbValidateGC(pGC, changes, pDrawable)
new_rotate = (oldOrg.x != pGC->lastWinOrg.x) ||
(oldOrg.y != pGC->lastWinOrg.y);
- devPriv = ((mfbPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr));
-
+ devPriv = (mfbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
/*
if the client clip is different or moved OR
the subwindowMode has changed OR
diff --git a/mfb/mfbimggblt.c b/mfb/mfbimggblt.c
index c21e82608..cb532cf3b 100644
--- a/mfb/mfbimggblt.c
+++ b/mfb/mfbimggblt.c
@@ -184,7 +184,8 @@ MFBIMAGEGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
but that is usually not a cheap thing to do.
*/
- pPrivGC = pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ pPrivGC = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
oldFillArea = pPrivGC->FillArea;
if (pGC->bgPixel & 1)
diff --git a/mfb/mfbline.c b/mfb/mfbline.c
index 863a6187b..65baa5efd 100644
--- a/mfb/mfbline.c
+++ b/mfb/mfbline.c
@@ -146,7 +146,8 @@ mfbLineSS (pDrawable, pGC, mode, npt, pptInit)
return;
cclip = pGC->pCompositeClip;
- alu = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
+ alu = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop;
pboxInit = REGION_RECTS(cclip);
nboxInit = REGION_NUM_RECTS(cclip);
@@ -525,7 +526,8 @@ mfbLineSD( pDrawable, pGC, mode, npt, pptInit)
return;
cclip = pGC->pCompositeClip;
- fgrop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
+ fgrop = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop;
pboxInit = REGION_RECTS(cclip);
nboxInit = REGION_NUM_RECTS(cclip);
diff --git a/mfb/mfbpixmap.c b/mfb/mfbpixmap.c
index 377398534..34bb33d89 100644
--- a/mfb/mfbpixmap.c
+++ b/mfb/mfbpixmap.c
@@ -115,6 +115,7 @@ mfbDestroyPixmap(pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/mfb/mfbpolypnt.c b/mfb/mfbpolypnt.c
index 1c4045126..146cfdce0 100644
--- a/mfb/mfbpolypnt.c
+++ b/mfb/mfbpolypnt.c
@@ -88,7 +88,8 @@ mfbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
if (!(pGC->planemask & 1))
return;
- pGCPriv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ pGCPriv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
rop = pGCPriv->rop;
mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrl);
diff --git a/mfb/mfbscrinit.c b/mfb/mfbscrinit.c
index 6d364b76c..8873a1ba1 100644
--- a/mfb/mfbscrinit.c
+++ b/mfb/mfbscrinit.c
@@ -68,11 +68,11 @@ SOFTWARE.
#include "servermd.h"
#ifdef PIXMAP_PER_WINDOW
-int frameWindowPrivateIndex;
-int frameGetWindowPrivateIndex(void) { return frameWindowPrivateIndex; }
+static DevPrivateKey frameWindowPrivateKey = &frameWindowPrivateKey;
+DevPrivateKey frameGetWindowPrivateKey(void) { return frameWindowPrivateKey; }
#endif
-int mfbGCPrivateIndex;
-int mfbGetGCPrivateIndex(void) { return mfbGCPrivateIndex; }
+static DevPrivateKey mfbGCPrivateKey = &mfbGCPrivateKey;
+DevPrivateKey mfbGetGCPrivateKey(void) { return mfbGCPrivateKey; }
static unsigned long mfbGeneration = 0;
static VisualRec visual = {
@@ -88,23 +88,19 @@ static DepthRec depth = {
};
Bool
-mfbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
+mfbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
{
if (mfbGeneration != serverGeneration)
{
-#ifdef PIXMAP_PER_WINDOW
- frameWindowPrivateIndex = AllocateWindowPrivateIndex();
-#endif
- mfbGCPrivateIndex = miAllocateGCPrivateIndex();
visual.vid = FakeClientID(0);
VID = visual.vid;
mfbGeneration = serverGeneration;
}
- if (pGCIndex)
- *pGCIndex = mfbGCPrivateIndex;
+ if (pGCKey)
+ *pGCKey = mfbGCPrivateKey;
pScreen->GetWindowPixmap = mfbGetWindowPixmap;
pScreen->SetWindowPixmap = mfbSetWindowPixmap;
- return AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC));
+ return dixRequestPrivate(mfbGCPrivateKey, sizeof(mfbPrivGC));
}
@@ -154,7 +150,8 @@ mfbGetWindowPixmap(pWin)
WindowPtr pWin;
{
#ifdef PIXMAP_PER_WINDOW
- return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
+ return (PixmapPtr)dixLookupPrivate(&pWin->devPrivates,
+ frameWindowPrivateKey);
#else
ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -168,7 +165,7 @@ mfbSetWindowPixmap(pWin, pPix)
PixmapPtr pPix;
{
#ifdef PIXMAP_PER_WINDOW
- pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
+ dixSetPrivate(&pWin->devPrivates, frameWindowPrivateKey, pPix);
#else
(* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
#endif
diff --git a/mfb/mfbwindow.c b/mfb/mfbwindow.c
index 30b8857b1..37125da45 100644
--- a/mfb/mfbwindow.c
+++ b/mfb/mfbwindow.c
@@ -55,6 +55,7 @@ SOFTWARE.
#include <X11/X.h>
#include "scrnintstr.h"
#include "windowstr.h"
+#include "privates.h"
#include "mfb.h"
#include "mistruct.h"
#include "regionstr.h"
diff --git a/mfb/mfbzerarc.c b/mfb/mfbzerarc.c
index 964e2f100..624e45fee 100644
--- a/mfb/mfbzerarc.c
+++ b/mfb/mfbzerarc.c
@@ -92,7 +92,8 @@ mfbZeroArcSS(
PixelType pmask;
register PixelType *paddr;
- if (((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop ==
+ if (((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop ==
RROP_BLACK)
pixel = 0;
else
diff --git a/mi/mi.h b/mi/mi.h
index c71c9b7c0..8d8f488a0 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -55,6 +55,7 @@ SOFTWARE.
#include <X11/fonts/font.h>
#include "input.h"
#include "cursor.h"
+#include "privates.h"
#define MiBits CARD32
@@ -412,7 +413,7 @@ extern Bool miScreenInit(
VisualPtr /*visuals*/
);
-extern int miAllocateGCPrivateIndex(
+extern DevPrivateKey miAllocateGCPrivateIndex(
void
);
diff --git a/mi/mibank.c b/mi/mibank.c
index 859770cc2..ea79e9d36 100644
--- a/mi/mibank.c
+++ b/mi/mibank.c
@@ -175,15 +175,15 @@ typedef struct _miBankQueue
#define xalloc_ARRAY(atype, ntype) \
(atype *)xalloc((ntype) * sizeof(atype))
-static int miBankScreenIndex;
-static int miBankGCIndex;
+static DevPrivateKey miBankScreenKey = &miBankScreenKey;
+static DevPrivateKey miBankGCKey = &miBankGCKey;
static unsigned long miBankGeneration = 0;
-#define BANK_SCRPRIVLVAL pScreen->devPrivates[miBankScreenIndex].ptr
+#define BANK_SCRPRIVLVAL dixLookupPrivate(&pScreen->devPrivates, miBankScreenKey)
#define BANK_SCRPRIVATE ((miBankScreenPtr)(BANK_SCRPRIVLVAL))
-#define BANK_GCPRIVLVAL(pGC) (pGC)->devPrivates[miBankGCIndex].ptr
+#define BANK_GCPRIVLVAL(pGC) dixLookupPrivate(&(pGC)->devPrivates, miBankGCKey)
#define BANK_GCPRIVATE(pGC) ((miBankGCPtr)(BANK_GCPRIVLVAL(pGC)))
@@ -2047,15 +2047,9 @@ miInitializeBanking(
/* Private areas */
if (miBankGeneration != serverGeneration)
- {
- if (((miBankScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((miBankGCIndex = AllocateGCPrivateIndex()) < 0))
- return FALSE;
-
miBankGeneration = serverGeneration;
- }
- if (!AllocateGCPrivate(pScreen, miBankGCIndex,
+ if (!dixRequestPrivate(miBankGCKey,
(nBanks * sizeof(RegionPtr)) +
(sizeof(miBankGCRec) - sizeof(RegionPtr))))
return FALSE;
@@ -2202,7 +2196,7 @@ miInitializeBanking(
SCREEN_WRAP(CreateGC, miBankCreateGC);
SCREEN_WRAP(CopyWindow, miBankCopyWindow);
- BANK_SCRPRIVLVAL = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miBankScreenKey, pScreenPriv);
return TRUE;
}
diff --git a/mi/midispcur.c b/mi/midispcur.c
index 918e401a5..45e0e9abe 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -54,8 +54,7 @@ in this Software without prior written authorization from The Open Group.
/* per-screen private data */
-static int miDCScreenIndex;
-static unsigned long miDCGeneration = 0;
+static DevPrivateKey miDCScreenKey = &miDCScreenKey;
static Bool miDCCloseScreen(int index, ScreenPtr pScreen);
@@ -117,13 +116,6 @@ miDCInitialize (pScreen, screenFuncs)
{
miDCScreenPtr pScreenPriv;
- if (miDCGeneration != serverGeneration)
- {
- miDCScreenIndex = AllocateScreenPrivateIndex ();
- if (miDCScreenIndex < 0)
- return FALSE;
- miDCGeneration = serverGeneration;
- }
pScreenPriv = (miDCScreenPtr) xalloc (sizeof (miDCScreenRec));
if (!pScreenPriv)
return FALSE;
@@ -149,7 +141,7 @@ miDCInitialize (pScreen, screenFuncs)
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = miDCCloseScreen;
- pScreen->devPrivates[miDCScreenIndex].ptr = (pointer) pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miDCScreenKey, pScreenPriv);
if (!miSpriteInitialize (pScreen, &miDCFuncs, screenFuncs))
{
@@ -170,7 +162,8 @@ miDCCloseScreen (index, pScreen)
{
miDCScreenPtr pScreenPriv;
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
tossGC (pScreenPriv->pSourceGC);
tossGC (pScreenPriv->pMaskGC);
@@ -194,7 +187,7 @@ miDCRealizeCursor (pScreen, pCursor)
CursorPtr pCursor;
{
if (pCursor->bits->refcnt <= 1)
- pCursor->bits->devPriv[pScreen->myNum] = (pointer)NULL;
+ dixSetPrivate(&pCursor->bits->devPrivates, pScreen, NULL);
return TRUE;
}
@@ -295,7 +288,7 @@ miDCRealize (
xfree ((pointer) pPriv);
return (miDCCursorPtr)NULL;
}
- pCursor->bits->devPriv[pScreen->myNum] = (pointer) pPriv;
+ dixSetPrivate(&pCursor->bits->devPrivates, pScreen, pPriv);
return pPriv;
}
pPriv->pPicture = 0;
@@ -313,7 +306,7 @@ miDCRealize (
xfree ((pointer) pPriv);
return (miDCCursorPtr)NULL;
}
- pCursor->bits->devPriv[pScreen->myNum] = (pointer) pPriv;
+ dixSetPrivate(&pCursor->bits->devPrivates, pScreen, pPriv);
/* create the two sets of bits, clipping as appropriate */
@@ -359,7 +352,8 @@ miDCUnrealizeCursor (pScreen, pCursor)
{
miDCCursorPtr pPriv;
- pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum];
+ pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
+ pScreen);
if (pPriv && (pCursor->bits->refcnt <= 1))
{
if (pPriv->sourceBits)
@@ -371,7 +365,7 @@ miDCUnrealizeCursor (pScreen, pCursor)
FreePicture (pPriv->pPicture, 0);
#endif
xfree ((pointer) pPriv);
- pCursor->bits->devPriv[pScreen->myNum] = (pointer)NULL;
+ dixSetPrivate(&pCursor->bits->devPrivates, pScreen, NULL);
}
return TRUE;
}
@@ -448,7 +442,8 @@ miDCMakeGC(
gcvals[0] = IncludeInferiors;
gcvals[1] = FALSE;
pGC = CreateGC((DrawablePtr)pWin,
- GCSubwindowMode|GCGraphicsExposures, gcvals, &status);
+ GCSubwindowMode|GCGraphicsExposures, gcvals, &status,
+ (XID)0, serverClient);
*ppGC = pGC;
return pGC;
}
@@ -465,14 +460,16 @@ miDCPutUpCursor (pScreen, pCursor, x, y, source, mask)
miDCCursorPtr pPriv;
WindowPtr pWin;
- pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum];
+ pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
+ pScreen);
if (!pPriv)
{
pPriv = miDCRealize(pScreen, pCursor);
if (!pPriv)
return FALSE;
}
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pWin = WindowTable[pScreen->myNum];
#ifdef ARGB_CURSOR
if (pPriv->pPicture)
@@ -517,7 +514,8 @@ miDCSaveUnderCursor (pScreen, x, y, w, h)
WindowPtr pWin;
GCPtr pGC;
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pSave = pScreenPriv->pSave;
pWin = WindowTable[pScreen->myNum];
if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h)
@@ -549,7 +547,8 @@ miDCRestoreUnderCursor (pScreen, x, y, w, h)
WindowPtr pWin;
GCPtr pGC;
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pSave = pScreenPriv->pSave;
pWin = WindowTable[pScreen->myNum];
if (!pSave)
@@ -575,7 +574,8 @@ miDCChangeSave (pScreen, x, y, w, h, dx, dy)
GCPtr pGC;
int sourcex, sourcey, destx, desty, copyw, copyh;
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pSave = pScreenPriv->pSave;
pWin = WindowTable[pScreen->myNum];
/*
@@ -711,14 +711,16 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
XID gcval = FALSE;
PixmapPtr pTemp;
- pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum];
+ pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
+ pScreen);
if (!pPriv)
{
pPriv = miDCRealize(pScreen, pCursor);
if (!pPriv)
return FALSE;
}
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pWin = WindowTable[pScreen->myNum];
pTemp = pScreenPriv->pTemp;
if (!pTemp ||
@@ -742,7 +744,7 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
if (!pScreenPriv->pMoveGC)
{
pScreenPriv->pMoveGC = CreateGC ((DrawablePtr)pTemp,
- GCGraphicsExposures, &gcval, &status);
+ GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
if (!pScreenPriv->pMoveGC)
return FALSE;
}
@@ -778,14 +780,14 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
if (!pScreenPriv->pPixSourceGC)
{
pScreenPriv->pPixSourceGC = CreateGC ((DrawablePtr)pTemp,
- GCGraphicsExposures, &gcval, &status);
+ GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
if (!pScreenPriv->pPixSourceGC)
return FALSE;
}
if (!pScreenPriv->pPixMaskGC)
{
pScreenPriv->pPixMaskGC = CreateGC ((DrawablePtr)pTemp,
- GCGraphicsExposures, &gcval, &status);
+ GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
if (!pScreenPriv->pPixMaskGC)
return FALSE;
}
diff --git a/mi/mieq.c b/mi/mieq.c
index 20c4b6201..d946e7d04 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -200,13 +200,13 @@ mieqProcessInputEvents(void)
while (miEventQueue.head != miEventQueue.tail) {
if (screenIsSaved == SCREEN_SAVER_ON)
- SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
+ dixSaveScreens (serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
#ifdef DPMSExtension
else if (DPMSPowerLevel != DPMSModeOn)
SetScreenSaverTimer();
if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(DPMSModeOn);
+ DPMSSet(serverClient, DPMSModeOn);
#endif
e = &miEventQueue.events[miEventQueue.head];
diff --git a/mi/miinitext.c b/mi/miinitext.c
index f5654f6bc..d06ab8ad1 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -248,6 +248,9 @@ typedef void (*InitExtension)(INITARGS);
#include "securitysrv.h"
#include <X11/extensions/securstr.h>
#endif
+#ifdef XSELINUX
+#include "xselinux.h"
+#endif
#ifdef PANORAMIX
#include <X11/extensions/panoramiXproto.h>
#endif
@@ -318,9 +321,11 @@ extern void XagExtensionInit(INITARGS);
extern void XaceExtensionInit(INITARGS);
#endif
#ifdef XCSECURITY
-extern void SecurityExtensionSetup(INITARGS);
extern void SecurityExtensionInit(INITARGS);
#endif
+#ifdef XSELINUX
+extern void XSELinuxExtensionInit(INITARGS);
+#endif
#ifdef XPRINT
extern void XpExtensionInit(INITARGS);
#endif
@@ -523,9 +528,6 @@ InitExtensions(argc, argv)
int argc;
char *argv[];
{
-#ifdef XCSECURITY
- SecurityExtensionSetup();
-#endif
#ifdef PANORAMIX
# if !defined(PRINT_ONLY_SERVER) && !defined(NO_PANORAMIX)
if (!noPanoramiXExtension) PanoramiXExtensionInit();
@@ -594,6 +596,9 @@ InitExtensions(argc, argv)
#ifdef XCSECURITY
if (!noSecurityExtension) SecurityExtensionInit();
#endif
+#ifdef XSELINUX
+ XSELinuxExtensionInit();
+#endif
#ifdef XPRINT
XpExtensionInit(); /* server-specific extension, cannot be disabled */
#endif
@@ -686,7 +691,10 @@ static ExtensionModule staticExtensions[] = {
{ XaceExtensionInit, XACE_EXTENSION_NAME, NULL, NULL, NULL },
#endif
#ifdef XCSECURITY
- { SecurityExtensionInit, SECURITY_EXTENSION_NAME, &noSecurityExtension, SecurityExtensionSetup, NULL },
+ { SecurityExtensionInit, SECURITY_EXTENSION_NAME, &noSecurityExtension, NULL, NULL },
+#endif
+#ifdef XSELINUX
+ { XSELinuxExtensionInit, XSELINUX_EXTENSION_NAME, NULL, NULL, NULL },
#endif
#ifdef XPRINT
{ XpExtensionInit, XP_PRINTNAME, NULL, NULL, NULL },
diff --git a/mi/miline.h b/mi/miline.h
index b97b8cf9d..036c2b5df 100644
--- a/mi/miline.h
+++ b/mi/miline.h
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#ifndef MILINE_H
#include "screenint.h"
+#include "privates.h"
/*
* Public definitions used for configuring basic pixelization aspects
@@ -119,9 +120,8 @@ extern void miSetZeroLineBias(
t = y1; y1 = y2; y2 = t;\
}
-#define miGetZeroLineBias(_pScreen) \
- ((miZeroLineScreenIndex < 0) ? \
- 0 : ((_pScreen)->devPrivates[miZeroLineScreenIndex].uval))
+#define miGetZeroLineBias(_pScreen) ((unsigned long) \
+ dixLookupPrivate(&(_pScreen)->devPrivates, miZeroLineScreenKey))
#define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \
(_octant) = 0; \
@@ -148,7 +148,7 @@ extern void miSetZeroLineBias(
#define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING)
#define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING)
-extern int miZeroLineScreenIndex;
+extern DevPrivateKey miZeroLineScreenKey;
extern int miZeroClipLine(
int /*xmin*/,
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 1dd28b85b..a0adac54d 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -10,6 +10,7 @@
#include "mi.h"
#include "gcstruct.h"
#include "regionstr.h"
+#include "privates.h"
#include "mivalidate.h"
#include "mioverlay.h"
#include "migc.h"
@@ -53,9 +54,8 @@ typedef struct {
Bool copyUnderlay;
} miOverlayScreenRec, *miOverlayScreenPtr;
-static unsigned long miOverlayGeneration = 0;
-static int miOverlayWindowIndex = -1;
-static int miOverlayScreenIndex = -1;
+static DevPrivateKey miOverlayWindowKey = &miOverlayWindowKey;
+static DevPrivateKey miOverlayScreenKey = &miOverlayScreenKey;
static void RebuildTree(WindowPtr);
static Bool HasUnderlayChildren(WindowPtr);
@@ -85,10 +85,10 @@ static void miOverlaySetShape(WindowPtr);
#endif
static void miOverlayChangeBorderWidth(WindowPtr, unsigned int);
-#define MIOVERLAY_GET_SCREEN_PRIVATE(pScreen) \
- ((miOverlayScreenPtr)((pScreen)->devPrivates[miOverlayScreenIndex].ptr))
-#define MIOVERLAY_GET_WINDOW_PRIVATE(pWin) \
- ((miOverlayWindowPtr)((pWin)->devPrivates[miOverlayWindowIndex].ptr))
+#define MIOVERLAY_GET_SCREEN_PRIVATE(pScreen) ((miOverlayScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, miOverlayScreenKey))
+#define MIOVERLAY_GET_WINDOW_PRIVATE(pWin) ((miOverlayWindowPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, miOverlayWindowKey))
#define MIOVERLAY_GET_WINDOW_TREE(pWin) \
(MIOVERLAY_GET_WINDOW_PRIVATE(pWin)->tree)
@@ -112,22 +112,13 @@ miInitOverlay(
if(!inOverlayFunc || !transFunc) return FALSE;
- if(miOverlayGeneration != serverGeneration) {
- if(((miOverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((miOverlayWindowIndex = AllocateWindowPrivateIndex()) < 0))
- return FALSE;
-
- miOverlayGeneration = serverGeneration;
- }
-
- if(!AllocateWindowPrivate(pScreen, miOverlayWindowIndex,
- sizeof(miOverlayWindowRec)))
+ if(!dixRequestPrivate(miOverlayWindowKey, sizeof(miOverlayWindowRec)))
return FALSE;
if(!(pScreenPriv = xalloc(sizeof(miOverlayScreenRec))))
return FALSE;
- pScreen->devPrivates[miOverlayScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miOverlayScreenKey, pScreenPriv);
pScreenPriv->InOverlay = inOverlayFunc;
pScreenPriv->MakeTransparent = transFunc;
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 24ff4cc53..2c3c68913 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -41,10 +41,10 @@ in this Software without prior written authorization from The Open Group.
# include "dixstruct.h"
# include "inputstr.h"
-_X_EXPORT int miPointerScreenIndex;
-static unsigned long miPointerGeneration = 0;
+_X_EXPORT DevPrivateKey miPointerScreenKey = &miPointerScreenKey;
-#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr))
+#define GetScreenPrivate(s) ((miPointerScreenPtr) \
+ dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
#define SetupScreen(s) miPointerScreenPtr pScreenPriv = GetScreenPrivate(s)
/*
@@ -76,13 +76,6 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate)
{
miPointerScreenPtr pScreenPriv;
- if (miPointerGeneration != serverGeneration)
- {
- miPointerScreenIndex = AllocateScreenPrivateIndex();
- if (miPointerScreenIndex < 0)
- return FALSE;
- miPointerGeneration = serverGeneration;
- }
pScreenPriv = (miPointerScreenPtr) xalloc (sizeof (miPointerScreenRec));
if (!pScreenPriv)
return FALSE;
@@ -99,7 +92,7 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate)
pScreenPriv->showTransparent = FALSE;
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = miPointerCloseScreen;
- pScreen->devPrivates[miPointerScreenIndex].ptr = (pointer) pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miPointerScreenKey, pScreenPriv);
/*
* set up screen cursor method table
*/
diff --git a/mi/mipointer.h b/mi/mipointer.h
index 1bce42c26..e864fddf4 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include "cursor.h"
#include "input.h"
+#include "privates.h"
typedef struct _miPointerSpriteFuncRec {
Bool (*RealizeCursor)(
@@ -166,6 +167,6 @@ extern void miPointerSetPosition(
extern void miPointerUpdateSprite(
DeviceIntPtr pDev);
-extern int miPointerScreenIndex;
+extern DevPrivateKey miPointerScreenKey;
#endif /* MIPOINTER_H */
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index 7a9014aa8..a1fb2e2f6 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -293,35 +293,22 @@ miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
return miScreenDevPrivateInit(pScreen, width, pbits);
}
-_X_EXPORT int
+static DevPrivateKey privateKey = &privateKey;
+
+_X_EXPORT DevPrivateKey
miAllocateGCPrivateIndex()
{
- static int privateIndex = -1;
- static unsigned long miGeneration = 0;
-
- if (miGeneration != serverGeneration)
- {
- privateIndex = AllocateGCPrivateIndex();
- miGeneration = serverGeneration;
- }
- return privateIndex;
+ return privateKey;
}
-_X_EXPORT int miZeroLineScreenIndex;
-static unsigned int miZeroLineGeneration = 0;
+_X_EXPORT DevPrivateKey miZeroLineScreenKey;
_X_EXPORT void
miSetZeroLineBias(pScreen, bias)
ScreenPtr pScreen;
unsigned int bias;
{
- if (miZeroLineGeneration != serverGeneration)
- {
- miZeroLineScreenIndex = AllocateScreenPrivateIndex();
- miZeroLineGeneration = serverGeneration;
- }
- if (miZeroLineScreenIndex >= 0)
- pScreen->devPrivates[miZeroLineScreenIndex].uval = bias;
+ dixSetPrivate(&pScreen->devPrivates, miZeroLineScreenKey, (pointer)bias);
}
_X_EXPORT PixmapPtr
diff --git a/mi/misprite.c b/mi/misprite.c
index 0b402fa59..0af3368b6 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -67,8 +67,7 @@ in this Software without prior written authorization from The Open Group.
* screen wrappers
*/
-static int miSpriteScreenIndex;
-static unsigned long miSpriteGeneration = 0;
+static DevPrivateKey miSpriteScreenKey = &miSpriteScreenKey;
static Bool miSpriteCloseScreen(int i, ScreenPtr pScreen);
static void miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy,
@@ -91,10 +90,9 @@ static void miSpriteStoreColors(ColormapPtr pMap, int ndef,
static void miSpriteComputeSaved(ScreenPtr pScreen);
-#define SCREEN_PROLOGUE(pScreen, field)\
- ((pScreen)->field = \
- ((miSpriteScreenPtr) (pScreen)->devPrivates[miSpriteScreenIndex].ptr)->field)
-
+#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
+ ((miSpriteScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
+ miSpriteScreenKey))->field)
#define SCREEN_EPILOGUE(pScreen, field)\
((pScreen)->field = miSprite##field)
@@ -128,8 +126,8 @@ miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
ScreenPtr pScreen = closure;
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pScreenPriv->isUp &&
RECT_IN_REGION (pScreen, pRegion, &pScreenPriv->saved) != rgnOUT)
{
@@ -156,14 +154,6 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs)
if (!DamageSetup (pScreen))
return FALSE;
- if (miSpriteGeneration != serverGeneration)
- {
- miSpriteScreenIndex = AllocateScreenPrivateIndex ();
- if (miSpriteScreenIndex < 0)
- return FALSE;
- miSpriteGeneration = serverGeneration;
- }
-
pScreenPriv = (miSpriteScreenPtr) xalloc (sizeof (miSpriteScreenRec));
if (!pScreenPriv)
return FALSE;
@@ -214,7 +204,7 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs)
pScreenPriv->colors[MASK_COLOR].red = 0;
pScreenPriv->colors[MASK_COLOR].green = 0;
pScreenPriv->colors[MASK_COLOR].blue = 0;
- pScreen->devPrivates[miSpriteScreenIndex].ptr = (pointer) pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miSpriteScreenKey, pScreenPriv);
pScreen->CloseScreen = miSpriteCloseScreen;
pScreen->GetImage = miSpriteGetImage;
@@ -247,8 +237,8 @@ miSpriteCloseScreen (i, pScreen)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->GetImage = pScreenPriv->GetImage;
pScreen->GetSpans = pScreenPriv->GetSpans;
@@ -278,8 +268,8 @@ miSpriteGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine)
SCREEN_PROLOGUE (pScreen, GetImage);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pDrawable->type == DRAWABLE_WINDOW &&
pScreenPriv->isUp &&
ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, sx, sy, w, h))
@@ -308,8 +298,8 @@ miSpriteGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
SCREEN_PROLOGUE (pScreen, GetSpans);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp)
{
DDXPointPtr pts;
@@ -350,8 +340,8 @@ miSpriteSourceValidate (pDrawable, x, y, width, height)
SCREEN_PROLOGUE (pScreen, SourceValidate);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp &&
ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y,
x, y, width, height))
@@ -374,7 +364,8 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
SCREEN_PROLOGUE (pScreen, CopyWindow);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
/*
* Damage will take care of destination check
*/
@@ -399,8 +390,8 @@ miSpriteBlockHandler (i, blockData, pTimeout, pReadmask)
ScreenPtr pScreen = screenInfo.screens[i];
miSpriteScreenPtr pPriv;
- pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
SCREEN_PROLOGUE(pScreen, BlockHandler);
(*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
@@ -421,8 +412,8 @@ miSpriteInstallColormap (pMap)
ScreenPtr pScreen = pMap->pScreen;
miSpriteScreenPtr pPriv;
- pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
SCREEN_PROLOGUE(pScreen, InstallColormap);
(*pScreen->InstallColormap) (pMap);
@@ -450,8 +441,8 @@ miSpriteStoreColors (pMap, ndef, pdef)
int updated;
VisualPtr pVisual;
- pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
SCREEN_PROLOGUE(pScreen, StoreColors);
(*pScreen->StoreColors) (pMap, ndef, pdef);
@@ -518,7 +509,7 @@ static void
miSpriteFindColors (ScreenPtr pScreen)
{
miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr)
- pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
CursorPtr pCursor;
xColorItem *sourceColor, *maskColor;
@@ -562,7 +553,8 @@ miSpriteRealizeCursor (pScreen, pCursor)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pCursor == pScreenPriv->pCursor)
pScreenPriv->checkPixels = TRUE;
return (*pScreenPriv->funcs->RealizeCursor) (pScreen, pCursor);
@@ -575,7 +567,8 @@ miSpriteUnrealizeCursor (pScreen, pCursor)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
return (*pScreenPriv->funcs->UnrealizeCursor) (pScreen, pCursor);
}
@@ -588,7 +581,8 @@ miSpriteSetCursor (pScreen, pCursor, x, y)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (!pCursor)
{
pScreenPriv->shouldBeUp = FALSE;
@@ -688,7 +682,8 @@ miSpriteMoveCursor (pScreen, x, y)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
miSpriteSetCursor (pScreen, pScreenPriv->pCursor, x, y);
}
@@ -703,7 +698,8 @@ miSpriteRemoveCursor (pScreen)
miSpriteScreenPtr pScreenPriv;
DamageDrawInternal (pScreen, TRUE);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
miSpriteIsUpFALSE (pScreen, pScreenPriv);
pScreenPriv->pCacheWin = NullWindow;
if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pScreen,
@@ -732,7 +728,8 @@ miSpriteRestoreCursor (pScreen)
DamageDrawInternal (pScreen, TRUE);
miSpriteComputeSaved (pScreen);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
pCursor = pScreenPriv->pCursor;
x = pScreenPriv->x - (int)pCursor->bits->xhot;
y = pScreenPriv->y - (int)pCursor->bits->yhot;
@@ -767,7 +764,8 @@ miSpriteComputeSaved (pScreen)
int wpad, hpad;
CursorPtr pCursor;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
pCursor = pScreenPriv->pCursor;
x = pScreenPriv->x - (int)pCursor->bits->xhot;
y = pScreenPriv->y - (int)pCursor->bits->yhot;
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index bd49f3f0d..efb046948 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -43,13 +43,12 @@
#define CW_ASSERT(x) do {} while (0)
#endif
-int cwGCIndex;
-int cwScreenIndex;
-int cwWindowIndex;
+DevPrivateKey cwGCKey = &cwGCKey;
+DevPrivateKey cwScreenKey = &cwScreenKey;
+DevPrivateKey cwWindowKey = &cwWindowKey;
#ifdef RENDER
-int cwPictureIndex;
+DevPrivateKey cwPictureKey = &cwPictureKey;
#endif
-static unsigned long cwGeneration = 0;
extern GCOps cwGCOps;
static Bool
@@ -123,7 +122,7 @@ cwCreateBackingGC(GCPtr pGC, DrawablePtr pDrawable)
pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off);
pPriv->pBackingGC = CreateGC(pBackingDrawable, GCGraphicsExposures,
- &noexpose, &status);
+ &noexpose, &status, (XID)0, serverClient);
if (status != Success)
return FALSE;
@@ -237,7 +236,7 @@ cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
static void
cwChangeGC(GCPtr pGC, unsigned long mask)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -249,7 +248,7 @@ cwChangeGC(GCPtr pGC, unsigned long mask)
static void
cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
{
- cwGCPtr pPriv = (cwGCPtr)(pGCDst)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGCDst->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGCDst, pPriv);
@@ -261,7 +260,7 @@ cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
static void
cwDestroyGC(GCPtr pGC)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -275,7 +274,7 @@ cwDestroyGC(GCPtr pGC)
static void
cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -287,7 +286,7 @@ cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
static void
cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
- cwGCPtr pPriv = (cwGCPtr)(pgcDst)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pgcDst->devPrivates, cwGCKey);
FUNC_PROLOGUE(pgcDst, pPriv);
@@ -299,7 +298,7 @@ cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
static void
cwDestroyClip(GCPtr pGC)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -478,34 +477,14 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
Bool has_render = GetPictureScreenIfSet(pScreen) != NULL;
#endif
- if (cwGeneration != serverGeneration)
- {
- cwScreenIndex = AllocateScreenPrivateIndex();
- if (cwScreenIndex < 0)
- return;
- cwGCIndex = AllocateGCPrivateIndex();
- cwWindowIndex = AllocateWindowPrivateIndex();
-#ifdef RENDER
- if (has_render)
- cwPictureIndex = AllocatePicturePrivateIndex();
-#endif
- cwGeneration = serverGeneration;
- }
- if (!AllocateGCPrivate(pScreen, cwGCIndex, sizeof(cwGCRec)))
- return;
- if (!AllocateWindowPrivate(pScreen, cwWindowIndex, 0))
+ if (!dixRequestPrivate(cwGCKey, sizeof(cwGCRec)))
return;
-#ifdef RENDER
- if (has_render) {
- if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0))
- return;
- }
-#endif
+
pScreenPriv = (cwScreenPtr)xalloc(sizeof(cwScreenRec));
if (!pScreenPriv)
return;
- pScreen->devPrivates[cwScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, cwScreenKey, pScreenPriv);
SCREEN_EPILOGUE(pScreen, CloseScreen, cwCloseScreen);
SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage);
@@ -530,8 +509,8 @@ cwCloseScreen (int i, ScreenPtr pScreen)
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- pScreenPriv = (cwScreenPtr)pScreen->devPrivates[cwScreenIndex].ptr;
-
+ pScreenPriv = (cwScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ cwScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->GetImage = pScreenPriv->GetImage;
pScreen->GetSpans = pScreenPriv->GetSpans;
diff --git a/miext/cw/cw.h b/miext/cw/cw.h
index a83949dc9..145f3492c 100644
--- a/miext/cw/cw.h
+++ b/miext/cw/cw.h
@@ -26,6 +26,7 @@
#include "gcstruct.h"
#include "picturestr.h"
+#include "privates.h"
/*
* One of these structures is allocated per GC that gets used with a window with
@@ -43,10 +44,10 @@ typedef struct {
GCFuncs *wrapFuncs; /* wrapped funcs */
} cwGCRec, *cwGCPtr;
-extern int cwGCIndex;
+extern DevPrivateKey cwGCKey;
-#define getCwGC(pGC) ((cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr)
-#define setCwGC(pGC,p) ((pGC)->devPrivates[cwGCIndex].ptr = (pointer) (p))
+#define getCwGC(pGC) ((cwGCPtr)dixLookupPrivate(&(pGC)->devPrivates, cwGCKey))
+#define setCwGC(pGC,p) dixSetPrivate(&(pGC)->devPrivates, cwGCKey, p)
/*
* One of these structures is allocated per Picture that gets used with a
@@ -59,17 +60,17 @@ typedef struct {
unsigned long stateChanges;
} cwPictureRec, *cwPicturePtr;
-#define getCwPicture(pPicture) \
- (pPicture->pDrawable ? (cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr : 0)
-#define setCwPicture(pPicture,p) ((pPicture)->devPrivates[cwPictureIndex].ptr = (pointer) (p))
+#define getCwPicture(pPicture) (pPicture->pDrawable ? \
+ (cwPicturePtr)dixLookupPrivate(&(pPicture)->devPrivates, cwPictureKey) : 0)
+#define setCwPicture(pPicture,p) dixSetPrivate(&(pPicture)->devPrivates, cwPictureKey, p)
-extern int cwPictureIndex;
+extern DevPrivateKey cwPictureKey;
+extern DevPrivateKey cwWindowKey;
-extern int cwWindowIndex;
-
-#define cwWindowPrivate(pWindow) ((pWindow)->devPrivates[cwWindowIndex].ptr)
+#define cwWindowPrivate(pWin) dixLookupPrivate(&(pWin)->devPrivates, cwWindowKey)
#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow))
-#define setCwPixmap(pWindow,pPixmap) (cwWindowPrivate(pWindow) = (pointer) (pPixmap))
+#define setCwPixmap(pWindow,pPixmap) \
+ dixSetPrivate(&(pWindow)->devPrivates, cwWindowKey, pPixmap)
#define cwDrawableIsRedirWindow(pDraw) \
((pDraw)->type == DRAWABLE_WINDOW && \
@@ -109,10 +110,10 @@ typedef struct {
#endif
} cwScreenRec, *cwScreenPtr;
-extern int cwScreenIndex;
+extern DevPrivateKey cwScreenKey;
-#define getCwScreen(pScreen) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr)
-#define setCwScreen(pScreen,p) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr = (p))
+#define getCwScreen(pScreen) ((cwScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, cwScreenKey))
+#define setCwScreen(pScreen,p) dixSetPrivate(&(pScreen)->devPrivates, cwScreenKey, p)
#define CW_OFFSET_XYPOINTS(ppt, npt) do { \
DDXPointPtr _ppt = (DDXPointPtr)(ppt); \
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 8f1e3b741..56864c56d 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -65,16 +65,15 @@
#define DAMAGE_DEBUG(x)
#endif
-#define getPixmapDamageRef(pPixmap) \
- ((DamagePtr *) &(pPixmap->devPrivates[damagePixPrivateIndex].ptr))
+#define getPixmapDamageRef(pPixmap) ((DamagePtr *) \
+ dixLookupPrivateAddr(&(pPixmap)->devPrivates, damagePixPrivateKey))
#define pixmapDamage(pPixmap) damagePixPriv(pPixmap)
-static int damageScrPrivateIndex;
-static int damagePixPrivateIndex;
-static int damageGCPrivateIndex;
-static int damageWinPrivateIndex;
-static int damageGeneration;
+static DevPrivateKey damageScrPrivateKey = &damageScrPrivateKey;
+static DevPrivateKey damagePixPrivateKey = &damagePixPrivateKey;
+static DevPrivateKey damageGCPrivateKey = &damageGCPrivateKey;
+static DevPrivateKey damageWinPrivateKey = &damageWinPrivateKey;
static DamagePtr *
getDrawableDamageRef (DrawablePtr pDrawable)
@@ -115,7 +114,7 @@ getDrawableDamageRef (DrawablePtr pDrawable)
#define winDamageRef(pWindow) \
DamagePtr *pPrev = (DamagePtr *) \
- &(pWindow->devPrivates[damageWinPrivateIndex].ptr)
+ dixLookupPrivateAddr(&(pWindow)->devPrivates, damageWinPrivateKey)
static void
DamageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion)
@@ -1745,30 +1744,10 @@ DamageSetup (ScreenPtr pScreen)
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- if (damageGeneration != serverGeneration)
- {
- damageScrPrivateIndex = AllocateScreenPrivateIndex ();
- if (damageScrPrivateIndex == -1)
- return FALSE;
- damageGCPrivateIndex = AllocateGCPrivateIndex ();
- if (damageGCPrivateIndex == -1)
- return FALSE;
- damagePixPrivateIndex = AllocatePixmapPrivateIndex ();
- if (damagePixPrivateIndex == -1)
- return FALSE;
- damageWinPrivateIndex = AllocateWindowPrivateIndex ();
- if (damageWinPrivateIndex == -1)
- return FALSE;
- damageGeneration = serverGeneration;
- }
- if (pScreen->devPrivates[damageScrPrivateIndex].ptr)
+ if (dixLookupPrivate(&pScreen->devPrivates, damageScrPrivateKey))
return TRUE;
- if (!AllocateGCPrivate (pScreen, damageGCPrivateIndex, sizeof (DamageGCPrivRec)))
- return FALSE;
- if (!AllocatePixmapPrivate (pScreen, damagePixPrivateIndex, 0))
- return FALSE;
- if (!AllocateWindowPrivate (pScreen, damageWinPrivateIndex, 0))
+ if (!dixRequestPrivate(damageGCPrivateKey, sizeof(DamageGCPrivRec)))
return FALSE;
pScrPriv = (DamageScrPrivPtr) xalloc (sizeof (DamageScrPrivRec));
@@ -1791,7 +1770,7 @@ DamageSetup (ScreenPtr pScreen)
}
#endif
- pScreen->devPrivates[damageScrPrivateIndex].ptr = (pointer) pScrPriv;
+ dixSetPrivate(&pScreen->devPrivates, damageScrPrivateKey, pScrPriv);
return TRUE;
}
diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h
index e603f02a4..2f6d53844 100755
--- a/miext/damage/damagestr.h
+++ b/miext/damage/damagestr.h
@@ -29,6 +29,7 @@
#include "damage.h"
#include "gcstruct.h"
+#include "privates.h"
#ifdef RENDER
# include "picturestr.h"
#endif
@@ -78,31 +79,31 @@ typedef struct _damageGCPriv {
} DamageGCPrivRec, *DamageGCPrivPtr;
/* XXX should move these into damage.c, damageScrPrivateIndex is static */
-#define damageGetScrPriv(pScr) \
- ((DamageScrPrivPtr) (pScr)->devPrivates[damageScrPrivateIndex].ptr)
+#define damageGetScrPriv(pScr) ((DamageScrPrivPtr) \
+ dixLookupPrivate(&(pScr)->devPrivates, damageScrPrivateKey))
#define damageScrPriv(pScr) \
DamageScrPrivPtr pScrPriv = damageGetScrPriv(pScr)
#define damageGetPixPriv(pPix) \
- ((DamagePtr) (pPix)->devPrivates[damagePixPrivateIndex].ptr)
+ dixLookupPrivate(&(pPix)->devPrivates, damagePixPrivateKey)
#define damgeSetPixPriv(pPix,v) \
- ((pPix)->devPrivates[damagePixPrivateIndex].ptr = (pointer ) (v))
+ dixSetPrivate(&(pPix)->devPrivates, damagePixPrivateKey, v)
#define damagePixPriv(pPix) \
DamagePtr pDamage = damageGetPixPriv(pPix)
#define damageGetGCPriv(pGC) \
- ((DamageGCPrivPtr) (pGC)->devPrivates[damageGCPrivateIndex].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, damageGCPrivateKey)
#define damageGCPriv(pGC) \
DamageGCPrivPtr pGCPriv = damageGetGCPriv(pGC)
#define damageGetWinPriv(pWin) \
- ((DamagePtr) (pWin)->devPrivates[damageWinPrivateIndex].ptr)
+ ((DamagePtr)dixLookupPrivate(&(pWin)->devPrivates, damageWinPrivateKey))
#define damageSetWinPriv(pWin,d) \
- ((pWin)->devPrivates[damageWinPrivateIndex].ptr = (d))
+ dixSetPrivate(&(pWin)->devPrivates, damageWinPrivateKey, d)
#endif /* _DAMAGESTR_H_ */
diff --git a/miext/rootless/accel/rlAccel.c b/miext/rootless/accel/rlAccel.c
index d62bee740..a14412416 100644
--- a/miext/rootless/accel/rlAccel.c
+++ b/miext/rootless/accel/rlAccel.c
@@ -46,10 +46,10 @@ typedef struct _rlAccelScreenRec {
CloseScreenProcPtr CloseScreen;
} rlAccelScreenRec, *rlAccelScreenPtr;
-static int rlAccelScreenPrivateIndex = -1;
+static DevPrivateKey rlAccelScreenPrivateKey = &rlAccelScreenPrivateKey;
-#define RLACCELREC(pScreen) \
- ((rlAccelScreenRec *)(pScreen)->devPrivates[rlAccelScreenPrivateIndex].ptr)
+#define RLACCELREC(pScreen) ((rlAccelScreenRec *) \
+ dixLookupPrivate(&(pScreen)->devPrivates, rlAccelScreenPrivateKey))
/* This is mostly identical to fbGCOps. */
static GCOps rlAccelOps = {
@@ -128,15 +128,8 @@ rlCloseScreen (int iScreen, ScreenPtr pScreen)
Bool
RootlessAccelInit(ScreenPtr pScreen)
{
- static unsigned long rlAccelGeneration = 0;
rlAccelScreenRec *s;
- if (rlAccelGeneration != serverGeneration) {
- rlAccelScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (rlAccelScreenPrivateIndex == -1) return FALSE;
- rlAccelGeneration = serverGeneration;
- }
-
s = xalloc(sizeof(rlAccelScreenRec));
if (!s) return FALSE;
RLACCELREC(pScreen) = s;
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index 562f65577..97c92d309 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -179,7 +179,7 @@ void RootlessStartDrawing(WindowPtr pWindow)
}
else
{
- PixmapPtr oldPixmap = pWindow->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr;
+ PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey);
if (oldPixmap != NULL)
{
if (oldPixmap == curPixmap)
@@ -187,7 +187,7 @@ void RootlessStartDrawing(WindowPtr pWindow)
else
RL_DEBUG_MSG("Window %p's existing oldPixmap %p being lost!\n", pWindow, oldPixmap);
}
- pWindow->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr = curPixmap;
+ dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, curPixmap);
pScreen->SetWindowPixmap(pWindow, winRec->pixmap);
}
}
@@ -203,7 +203,7 @@ static int RestorePreDrawingPixmapVisitor(WindowPtr pWindow, pointer data)
RootlessWindowRec *winRec = (RootlessWindowRec*)data;
ScreenPtr pScreen = pWindow->drawable.pScreen;
PixmapPtr exPixmap = pScreen->GetWindowPixmap(pWindow);
- PixmapPtr oldPixmap = pWindow->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr;
+ PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey);
if (oldPixmap == NULL)
{
if (exPixmap == winRec->pixmap)
@@ -216,7 +216,7 @@ static int RestorePreDrawingPixmapVisitor(WindowPtr pWindow, pointer data)
if (oldPixmap == winRec->pixmap)
RL_DEBUG_MSG("Window %p's oldPixmap %p is winRec->pixmap, which has just been freed!\n", pWindow, oldPixmap);
pScreen->SetWindowPixmap(pWindow, oldPixmap);
- pWindow->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr = NULL;
+ dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, NULL);
}
return WT_WALKCHILDREN;
}
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index fd8725a0c..9e4a14a04 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -57,10 +57,10 @@
// Global variables
-extern int rootlessGCPrivateIndex;
-extern int rootlessScreenPrivateIndex;
-extern int rootlessWindowPrivateIndex;
-extern int rootlessWindowOldPixmapPrivateIndex;
+extern DevPrivateKey rootlessGCPrivateKey;
+extern DevPrivateKey rootlessScreenPrivateKey;
+extern DevPrivateKey rootlessWindowPrivateKey;
+extern DevPrivateKey rootlessWindowOldPixmapPrivateKey;
// RootlessGCRec: private per-gc data
@@ -144,12 +144,17 @@ typedef struct _RootlessScreenRec {
// Accessors for screen and window privates
-#define SCREENREC(pScreen) \
- ((RootlessScreenRec *)(pScreen)->devPrivates[rootlessScreenPrivateIndex].ptr)
+#define SCREENREC(pScreen) ((RootlessScreenRec *) \
+ dixLookupPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey))
-#define WINREC(pWin) \
- ((RootlessWindowRec *)(pWin)->devPrivates[rootlessWindowPrivateIndex].ptr)
+#define SETSCREENREC(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey, v)
+#define WINREC(pWin) ((RootlessWindowRec *) \
+ dixLookupPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey))
+
+#define SETWINREC(pWin, v) \
+ dixSetPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey, v)
// Call a rootless implementation function.
// Many rootless implementation functions are allowed to be NULL.
diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index 7e0778e17..c80b11f1d 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -276,11 +276,11 @@ RootlessCreateGC(GCPtr pGC)
Bool result;
SCREEN_UNWRAP(pGC->pScreen, CreateGC);
- s = (RootlessScreenRec *) pGC->pScreen->
- devPrivates[rootlessScreenPrivateIndex].ptr;
+ s = SCREENREC(pGC->pScreen);
result = s->CreateGC(pGC);
- gcrec = (RootlessGCRec *) pGC->devPrivates[rootlessGCPrivateIndex].ptr;
+ gcrec = (RootlessGCRec *)
+ dixLookupPrivate(&pGC->devPrivates, rootlessGCPrivateKey);
gcrec->originalOps = NULL; // don't wrap ops yet
gcrec->originalFuncs = pGC->funcs;
pGC->funcs = &rootlessGCFuncs;
@@ -302,7 +302,7 @@ RootlessCreateGC(GCPtr pGC)
// does not assume ops have been wrapped
#define GCFUNC_UNWRAP(pGC) \
RootlessGCRec *gcrec = (RootlessGCRec *) \
- (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \
+ dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \
(pGC)->funcs = gcrec->originalFuncs; \
if (gcrec->originalOps) { \
(pGC)->ops = gcrec->originalOps; \
@@ -399,7 +399,7 @@ static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
// assumes both funcs and ops are wrapped
#define GCOP_UNWRAP(pGC) \
RootlessGCRec *gcrec = (RootlessGCRec *) \
- (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \
+ dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \
GCFuncs *saveFuncs = pGC->funcs; \
(pGC)->funcs = gcrec->originalFuncs; \
(pGC)->ops = gcrec->originalOps;
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 19dba6e5e..5031858dd 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -62,10 +62,10 @@ extern int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild,
extern Bool RootlessCreateGC(GCPtr pGC);
// Initialize globals
-int rootlessGCPrivateIndex = -1;
-int rootlessScreenPrivateIndex = -1;
-int rootlessWindowPrivateIndex = -1;
-int rootlessWindowOldPixmapPrivateIndex = -1;
+DevPrivateKey rootlessGCPrivateKey = &rootlessGCPrivateKey;
+DevPrivateKey rootlessScreenPrivateKey = &rootlessScreenPrivateKey;
+DevPrivateKey rootlessWindowPrivateKey = &rootlessWindowPrivateKey;
+DevPrivateKey rootlessWindowOldPixmapPrivateKey = &rootlessWindowOldPixmapPrivateKey;
/*
@@ -610,32 +610,14 @@ static Bool
RootlessAllocatePrivates(ScreenPtr pScreen)
{
RootlessScreenRec *s;
- static unsigned long rootlessGeneration = 0;
-
- if (rootlessGeneration != serverGeneration) {
- rootlessScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (rootlessScreenPrivateIndex == -1) return FALSE;
- rootlessGCPrivateIndex = AllocateGCPrivateIndex();
- if (rootlessGCPrivateIndex == -1) return FALSE;
- rootlessWindowPrivateIndex = AllocateWindowPrivateIndex();
- if (rootlessWindowPrivateIndex == -1) return FALSE;
- rootlessWindowOldPixmapPrivateIndex = AllocateWindowPrivateIndex();
- if (rootlessWindowOldPixmapPrivateIndex == -1) return FALSE;
- rootlessGeneration = serverGeneration;
- }
// no allocation needed for screen privates
- if (!AllocateGCPrivate(pScreen, rootlessGCPrivateIndex,
- sizeof(RootlessGCRec)))
- return FALSE;
- if (!AllocateWindowPrivate(pScreen, rootlessWindowPrivateIndex, 0))
- return FALSE;
- if (!AllocateWindowPrivate(pScreen, rootlessWindowOldPixmapPrivateIndex, 0))
+ if (!dixRequestPrivate(rootlessGCPrivateKey, sizeof(RootlessGCRec)))
return FALSE;
s = xalloc(sizeof(RootlessScreenRec));
if (! s) return FALSE;
- SCREENREC(pScreen) = s;
+ SETSCREENREC(pScreen, s);
s->pixmap_data = NULL;
s->pixmap_data_size = 0;
@@ -650,8 +632,7 @@ RootlessAllocatePrivates(ScreenPtr pScreen)
static void
RootlessWrap(ScreenPtr pScreen)
{
- RootlessScreenRec *s = (RootlessScreenRec*)
- pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;
+ RootlessScreenRec *s = SCREENREC(pScreen);
#define WRAP(a) \
if (pScreen->a) { \
@@ -718,8 +699,7 @@ Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs)
if (!RootlessAllocatePrivates(pScreen))
return FALSE;
- s = (RootlessScreenRec*)
- pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;
+ s = SCREENREC(pScreen);
s->imp = procs;
s->colormap = NULL;
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index bb5ba4828..b95339888 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -197,8 +197,8 @@ RootlessCreateWindow(WindowPtr pWin)
Bool result;
RegionRec saveRoot;
- WINREC(pWin) = NULL;
- pWin->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr = NULL;
+ SETWINREC(pWin, NULL);
+ dixSetPrivate(&pWin->devPrivates, rootlessWindowOldPixmapPrivateKey, NULL);
SCREEN_UNWRAP(pWin->drawable.pScreen, CreateWindow);
@@ -239,7 +239,7 @@ RootlessDestroyFrame(WindowPtr pWin, RootlessWindowPtr winRec)
#endif
xfree(winRec);
- WINREC(pWin) = NULL;
+ SETWINREC(pWin, NULL);
}
@@ -489,7 +489,7 @@ RootlessEnsureFrame(WindowPtr pWin)
winRec->pixmap = NULL;
winRec->wid = NULL;
- WINREC(pWin) = winRec;
+ SETWINREC(pWin, winRec);
#ifdef SHAPE
// Set the frame's shape if the window is shaped
@@ -506,7 +506,7 @@ RootlessEnsureFrame(WindowPtr pWin)
{
RL_DEBUG_MSG("implementation failed to create frame!\n");
xfree(winRec);
- WINREC(pWin) = NULL;
+ SETWINREC(pWin, NULL);
return NULL;
}
@@ -1437,8 +1437,8 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent)
/* Switch the frame record from one to the other. */
- WINREC(pWin) = NULL;
- WINREC(pTopWin) = winRec;
+ SETWINREC(pWin, NULL);
+ SETWINREC(pTopWin, winRec);
RootlessInitializeFrame(pTopWin, winRec);
RootlessReshapeFrame(pTopWin);
diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c
index 8aa192f62..ef0df4091 100644
--- a/miext/shadow/shadow.c
+++ b/miext/shadow/shadow.c
@@ -36,8 +36,7 @@
#include "gcstruct.h"
#include "shadow.h"
-int shadowScrPrivateIndex;
-int shadowGeneration;
+DevPrivateKey shadowScrPrivateKey = &shadowScrPrivateKey;
#define wrap(priv, real, mem) {\
priv->mem = real->mem; \
@@ -116,7 +115,8 @@ static void
shadowReportFunc(DamagePtr pDamage, RegionPtr pRegion, void *closure)
{
ScreenPtr pScreen = closure;
- shadowBufPtr pBuf = pScreen->devPrivates[shadowScrPrivateIndex].ptr;
+ shadowBufPtr pBuf = (shadowBufPtr)
+ dixLookupPrivate(&pScreen->devPrivates, shadowScrPrivateKey);
/* Register the damaged region, use DamageReportNone below when we
* want to break BC below... */
@@ -138,13 +138,6 @@ shadowSetup(ScreenPtr pScreen)
if (!DamageSetup(pScreen))
return FALSE;
- if (shadowGeneration != serverGeneration) {
- shadowScrPrivateIndex = AllocateScreenPrivateIndex();
- if (shadowScrPrivateIndex == -1)
- return FALSE;
- shadowGeneration = serverGeneration;
- }
-
pBuf = (shadowBufPtr) xalloc(sizeof(shadowBufRec));
if (!pBuf)
return FALSE;
@@ -175,7 +168,7 @@ shadowSetup(ScreenPtr pScreen)
REGION_NULL(pScreen, &pBuf->damage); /* bc */
#endif
- pScreen->devPrivates[shadowScrPrivateIndex].ptr = (pointer) pBuf;
+ dixSetPrivate(&pScreen->devPrivates, shadowScrPrivateKey, pBuf);
return TRUE;
}
diff --git a/miext/shadow/shadow.h b/miext/shadow/shadow.h
index 8986809f4..2e45df2b5 100644
--- a/miext/shadow/shadow.h
+++ b/miext/shadow/shadow.h
@@ -74,9 +74,10 @@ typedef struct _shadowBuf {
#define SHADOW_REFLECT_Y 32
#define SHADOW_REFLECT_ALL (SHADOW_REFLECT_X|SHADOW_REFLECT_Y)
-extern int shadowScrPrivateIndex;
+extern DevPrivateKey shadowScrPrivateKey;
-#define shadowGetBuf(pScr) ((shadowBufPtr) (pScr)->devPrivates[shadowScrPrivateIndex].ptr)
+#define shadowGetBuf(pScr) ((shadowBufPtr) \
+ dixLookupPrivate(&(pScr)->devPrivates, shadowScrPrivateKey))
#define shadowBuf(pScr) shadowBufPtr pBuf = shadowGetBuf(pScr)
#define shadowDamage(pBuf) DamageRegion(pBuf->pDamage)
diff --git a/os/Makefile.am b/os/Makefile.am
index 16070f5b8..ce6058538 100644
--- a/os/Makefile.am
+++ b/os/Makefile.am
@@ -3,7 +3,6 @@ noinst_LTLIBRARIES = libos.la
AM_CFLAGS = $(DIX_CFLAGS)
SECURERPC_SRCS = rpcauth.c
-XCSECURITY_SRCS = secauth.c
XDMCP_SRCS = xdmcp.c
STRLCAT_SRCS = strlcat.c strlcpy.c
XORG_SRCS = log.c
@@ -29,10 +28,6 @@ if SECURE_RPC
libos_la_SOURCES += $(SECURERPC_SRCS)
endif
-if XCSECURITY
-libos_la_SOURCES += $(XCSECURITY_SRCS)
-endif
-
if XDMCP
libos_la_SOURCES += $(XDMCP_SRCS)
endif
@@ -42,7 +37,7 @@ libos_la_SOURCES += $(STRLCAT_SRCS)
endif
EXTRA_DIST = $(SECURERPC_SRCS) $(INTERNALMALLOC_SRCS) \
- $(XCSECURITY_SRCS) $(XDMCP_SRCS) $(STRLCAT_SRCS)
+ $(XDMCP_SRCS) $(STRLCAT_SRCS)
if XSERVER_DTRACE
# Generate dtrace object code for probes in libos & libdix
diff --git a/os/WaitFor.c b/os/WaitFor.c
index e6d45e68e..c58f24888 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -563,7 +563,7 @@ TimerInit(void)
#define DPMS_CHECK_MODE(mode,time)\
if (time > 0 && DPMSPowerLevel < mode && timeout >= time)\
- DPMSSet(mode);
+ DPMSSet(serverClient, mode);
#define DPMS_CHECK_TIMEOUT(time)\
if (time > 0 && (time - timeout) > 0)\
@@ -632,7 +632,7 @@ ScreenSaverTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
}
ResetOsBuffers(); /* not ideal, but better than nothing */
- SaveScreens(SCREEN_SAVER_ON, ScreenSaverActive);
+ dixSaveScreens(serverClient, SCREEN_SAVER_ON, ScreenSaverActive);
if (ScreenSaverInterval > 0)
{
diff --git a/os/access.c b/os/access.c
index b0f63edc2..e91dd37e4 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1521,17 +1521,20 @@ FreeLocalClientCreds(LocalClientCredRec *lcc)
}
}
-static Bool
+static int
AuthorizedClient(ClientPtr client)
{
+ int rc;
+
if (!client || defeatAccessControl)
- return TRUE;
+ return Success;
/* untrusted clients can't change host access */
- if (!XaceHook(XACE_HOSTLIST_ACCESS, client, DixWriteAccess))
- return FALSE;
+ rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
+ if (rc != Success)
+ return rc;
- return LocalClient(client);
+ return LocalClient(client) ? Success : BadAccess;
}
/* Add a host to the access control list. This is the external interface
@@ -1543,10 +1546,11 @@ AddHost (ClientPtr client,
unsigned length, /* of bytes in pAddr */
pointer pAddr)
{
- int len;
+ int rc, len;
- if (!AuthorizedClient(client))
- return(BadAccess);
+ rc = AuthorizedClient(client);
+ if (rc != Success)
+ return rc;
switch (family) {
case FamilyLocalHost:
len = length;
@@ -1640,11 +1644,12 @@ RemoveHost (
unsigned length, /* of bytes in pAddr */
pointer pAddr)
{
- int len;
+ int rc, len;
register HOST *host, **prev;
- if (!AuthorizedClient(client))
- return(BadAccess);
+ rc = AuthorizedClient(client);
+ if (rc != Success)
+ return rc;
switch (family) {
case FamilyLocalHost:
len = length;
@@ -1901,8 +1906,9 @@ ChangeAccessControl(
ClientPtr client,
int fEnabled)
{
- if (!AuthorizedClient(client))
- return BadAccess;
+ int rc = AuthorizedClient(client);
+ if (rc != Success)
+ return rc;
AccessEnabled = fEnabled;
return Success;
}
diff --git a/os/auth.c b/os/auth.c
index fa3ba7924..dab4f60bd 100644
--- a/os/auth.c
+++ b/os/auth.c
@@ -42,9 +42,6 @@ from The Open Group.
# include "dixstruct.h"
# include <sys/types.h>
# include <sys/stat.h>
-#ifdef XCSECURITY
-# include "securitysrv.h"
-#endif
#ifdef WIN32
#include <X11/Xw32defs.h>
#endif
@@ -89,14 +86,6 @@ static struct protocol protocols[] = {
#endif
},
#endif
-#ifdef XCSECURITY
-{ (unsigned short) XSecurityAuthorizationNameLen,
- XSecurityAuthorizationName,
- NULL, AuthSecurityCheck, NULL,
- NULL, NULL, NULL,
- NULL
-},
-#endif
};
# define NUM_AUTHORIZATION (sizeof (protocols) /\
diff --git a/os/connection.c b/os/connection.c
index be7521f3d..3b5742c2b 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -143,9 +143,6 @@ SOFTWARE.
#include "appgroup.h"
#endif
#include "xace.h"
-#ifdef XCSECURITY
-#include "securitysrv.h"
-#endif
#ifdef X_NOT_POSIX
#define Pid_t int
@@ -719,13 +716,7 @@ ClientAuthorized(ClientPtr client,
if (auth_id == (XID) ~0L)
{
- if (
-#ifdef XCSECURITY
- (proto_n == 0 ||
- strncmp (auth_proto, XSecurityAuthorizationName, proto_n) != 0) &&
-#endif
- _XSERVTransGetPeerAddr (trans_conn,
- &family, &fromlen, &from) != -1)
+ if (_XSERVTransGetPeerAddr(trans_conn, &family, &fromlen, &from) != -1)
{
if (InvalidHost ((struct sockaddr *) from, fromlen, client))
AuthAudit(client, FALSE, (struct sockaddr *) from,
@@ -1147,11 +1138,15 @@ RemoveEnabledDevice(int fd)
* This routine is "undone" by ListenToAllClients()
*****************/
-void
+int
OnlyListenToOneClient(ClientPtr client)
{
OsCommPtr oc = (OsCommPtr)client->osPrivate;
- int connection = oc->fd;
+ int rc, connection = oc->fd;
+
+ rc = XaceHook(XACE_SERVER_ACCESS, client, DixGrabAccess);
+ if (rc != Success)
+ return rc;
if (! GrabInProgress)
{
@@ -1172,6 +1167,7 @@ OnlyListenToOneClient(ClientPtr client)
XFD_ORSET(&AllSockets, &AllSockets, &AllClients);
GrabInProgress = client->index;
}
+ return rc;
}
/****************
diff --git a/os/osdep.h b/os/osdep.h
index 2d455aa67..b6894c146 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -257,9 +257,6 @@ extern int SecureRPCRemove (AuthRemCArgs);
extern int SecureRPCReset (AuthRstCArgs);
#endif
-/* in secauth.c */
-extern XID AuthSecurityCheck (AuthCheckArgs);
-
/* in xdmcp.c */
extern void XdmcpUseMsg (void);
extern int XdmcpOptions(int argc, char **argv, int i);
diff --git a/os/secauth.c b/os/secauth.c
deleted file mode 100644
index d01879bfd..000000000
--- a/os/secauth.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
-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.
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "osdep.h"
-#include "dixstruct.h"
-#include "swaprep.h"
-
-#ifdef XCSECURITY
-#include "securitysrv.h"
-#endif
-
-static char InvalidPolicyReason[] = "invalid policy specification";
-static char PolicyViolationReason[] = "policy violation";
-
-static Bool
-AuthCheckSitePolicy(
- unsigned short *data_lengthP,
- char **dataP,
- ClientPtr client,
- char **reason)
-{
- CARD8 *policy = *(CARD8 **)dataP;
- int length;
- Bool permit;
- int nPolicies;
- char **sitePolicies;
- int nSitePolicies;
- Bool found = FALSE;
-
- if ((length = *data_lengthP) < 2) {
- *reason = InvalidPolicyReason;
- return FALSE;
- }
-
- permit = (*policy++ == 0);
- nPolicies = (CARD8) *policy++;
-
- length -= 2;
-
- sitePolicies = SecurityGetSitePolicyStrings(&nSitePolicies);
-
- while (nPolicies) {
- int strLen, sitePolicy;
-
- if (length == 0) {
- *reason = InvalidPolicyReason;
- return FALSE;
- }
-
- strLen = (CARD8) *policy++;
- if (--length < strLen) {
- *reason = InvalidPolicyReason;
- return FALSE;
- }
-
- if (!found)
- {
- for (sitePolicy = 0; sitePolicy < nSitePolicies; sitePolicy++)
- {
- char *testPolicy = sitePolicies[sitePolicy];
- if ((strLen == strlen(testPolicy)) &&
- (strncmp((char *)policy, testPolicy, strLen) == 0))
- {
- found = TRUE; /* need to continue parsing the policy... */
- break;
- }
- }
- }
-
- policy += strLen;
- length -= strLen;
- nPolicies--;
- }
-
- if (found != permit)
- {
- *reason = PolicyViolationReason;
- return FALSE;
- }
-
- *data_lengthP = length;
- *dataP = (char *)policy;
- return TRUE;
-}
-
-XID
-AuthSecurityCheck (
- unsigned short data_length,
- char *data,
- ClientPtr client,
- char **reason)
-{
-#ifdef XCSECURITY
- xConnSetupPrefix csp;
- xReq freq;
-
- if (client->clientState == ClientStateCheckedSecurity)
- {
- *reason = "repeated security check not permitted";
- return (XID) -1;
- }
- else if (data_length > 0)
- {
- char policy_mask = *data++;
-
- if (--data_length == 1) {
- *reason = InvalidPolicyReason;
- return (XID) -1;
- }
-
- if (policy_mask & 0x01) /* Extensions policy */
- {
- /* AuthCheckExtensionPolicy(&data_length, &data, client, reason) */
- *reason = "security policy not implemented";
- return (XID) -1;
- }
-
- if (policy_mask & 0x02) /* Site policy */
- {
- if (!AuthCheckSitePolicy(&data_length, &data, client, reason))
- return (XID) -1;
- }
-
- if (data_length > 0) { /* did we consume the whole policy? */
- *reason = InvalidPolicyReason;
- return (XID) -1;
- }
-
- }
- else if (!GetAccessControl())
- {
- /*
- * The client - possibly the X FireWall Proxy - gave
- * no auth data and host-based authorization is turned
- * off. In this case, the client should be denied
- * access to the X server.
- */
- *reason = "server host access control is disabled";
- return (XID) -1;
- }
-
- client->clientState = ClientStateCheckingSecurity;
-
- csp.success = 2 /* Authenticate */;
- csp.lengthReason = 0;
- csp.length = 0;
- csp.majorVersion = X_PROTOCOL;
- csp.minorVersion = X_PROTOCOL_REVISION;
- if (client->swapped)
- WriteSConnSetupPrefix(client, &csp);
- else
- (void)WriteToClient(client, sz_xConnSetupPrefix, (char *) &csp);
-
- /*
- * Next time the client sends the real auth data, we want
- * ProcEstablishConnection to be called.
- */
-
- freq.reqType = 1;
- freq.length = (sz_xReq + sz_xConnClientPrefix) >> 2;
- client->swapped = FALSE;
- if (!InsertFakeRequest(client, (char *)&freq, sz_xReq))
- {
- *reason = "internal error";
- return (XID) -1;
- }
-
- return (XID) 0;
-#else
- *reason = "method not supported";
- return (XID) -1;
-#endif
-}
diff --git a/os/utils.c b/os/utils.c
index d46a756f2..22f9541f5 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -123,9 +123,6 @@ OR PERFORMANCE OF THIS SOFTWARE.
#ifdef XKB
#include <xkbsrv.h>
#endif
-#ifdef XCSECURITY
-#include "securitysrv.h"
-#endif
#ifdef RENDER
#include "picture.h"
@@ -621,9 +618,6 @@ void UseMsg(void)
ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
#endif
ErrorF("-s # screen-saver timeout (minutes)\n");
-#ifdef XCSECURITY
- ErrorF("-sp file security policy file\n");
-#endif
#ifdef XPRINT
PrinterUseMsg();
#endif
@@ -1044,12 +1038,6 @@ ProcessCommandLine(int argc, char *argv[])
i = skip - 1;
}
#endif
-#ifdef XCSECURITY
- else if ((skip = XSecurityOptions(argc, argv, i)) != i)
- {
- i = skip - 1;
- }
-#endif
#ifdef AIXV3
else if ( strcmp( argv[i], "-timeout") == 0)
{
diff --git a/randr/randr.c b/randr/randr.c
index 958f9c192..bc2b995d2 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -56,9 +56,9 @@ static int SProcRRDispatch (ClientPtr pClient);
int RREventBase;
int RRErrorBase;
RESTYPE RRClientType, RREventType; /* resource types for event masks */
-int RRClientPrivateIndex;
+DevPrivateKey RRClientPrivateKey = &RRClientPrivateKey;
-int rrPrivIndex = -1;
+DevPrivateKey rrPrivKey = &rrPrivKey;
static void
RRClientCallback (CallbackListPtr *list,
@@ -214,8 +214,6 @@ Bool RRInit (void)
return TRUE;
}
-static int RRScreenGeneration;
-
Bool RRScreenInit(ScreenPtr pScreen)
{
rrScrPrivPtr pScrPriv;
@@ -223,13 +221,6 @@ Bool RRScreenInit(ScreenPtr pScreen)
if (!RRInit ())
return FALSE;
- if (RRScreenGeneration != serverGeneration)
- {
- if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- RRScreenGeneration = serverGeneration;
- }
-
pScrPriv = (rrScrPrivPtr) xcalloc (1, sizeof (rrScrPrivRec));
if (!pScrPriv)
return FALSE;
@@ -333,8 +324,7 @@ RRExtensionInit (void)
if (RRNScreens == 0) return;
- RRClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (RRClientPrivateIndex,
+ if (!dixRequestPrivate(RRClientPrivateKey,
sizeof (RRClientRec) +
screenInfo.numScreens * sizeof (RRTimesRec)))
return;
diff --git a/randr/randrstr.h b/randr/randrstr.h
index bd19fe9d0..e8358bc0c 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -262,11 +262,11 @@ typedef struct _rrScrPriv {
#endif
} rrScrPrivRec, *rrScrPrivPtr;
-extern int rrPrivIndex;
+extern DevPrivateKey rrPrivKey;
-#define rrGetScrPriv(pScr) ((rrScrPrivPtr) (pScr)->devPrivates[rrPrivIndex].ptr)
+#define rrGetScrPriv(pScr) ((rrScrPrivPtr)dixLookupPrivate(&(pScr)->devPrivates, rrPrivKey))
#define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr)
-#define SetRRScreen(s,p) ((s)->devPrivates[rrPrivIndex].ptr = (pointer) (p))
+#define SetRRScreen(s,p) dixSetPrivate(&(s)->devPrivates, rrPrivKey, p)
/*
* each window has a list of clients requesting
@@ -298,7 +298,7 @@ typedef struct _RRClient {
} RRClientRec, *RRClientPtr;
extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
-extern int RRClientPrivateIndex;
+extern DevPrivateKey RRClientPrivateKey;
extern RESTYPE RRCrtcType, RRModeType, RROutputType;
#define LookupOutput(client,id,a) ((RROutputPtr) \
@@ -311,7 +311,7 @@ extern RESTYPE RRCrtcType, RRModeType, RROutputType;
(SecurityLookupIDByType (client, id, \
RRModeType, a)))
-#define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr)
+#define GetRRClient(pClient) ((RRClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RRClientPrivateKey))
#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)
/* Initialize the extension */
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 4a7275bbf..7c22437a9 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -22,6 +22,7 @@
#include "randrstr.h"
#include "swaprep.h"
+#include "registry.h"
RESTYPE RRCrtcType;
@@ -501,9 +502,7 @@ RRCrtcInit (void)
RRCrtcType = CreateNewResourceType (RRCrtcDestroyResource);
if (!RRCrtcType)
return FALSE;
-#ifdef XResExtension
- RegisterResourceName (RRCrtcType, "CRTC");
-#endif
+ RegisterResourceName (RRCrtcType, "CRTC");
return TRUE;
}
diff --git a/randr/rrmode.c b/randr/rrmode.c
index f060d2294..d5072084a 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -21,6 +21,7 @@
*/
#include "randrstr.h"
+#include "registry.h"
RESTYPE RRModeType;
@@ -268,9 +269,7 @@ RRModeInit (void)
RRModeType = CreateNewResourceType (RRModeDestroyResource);
if (!RRModeType)
return FALSE;
-#ifdef XResExtension
RegisterResourceName (RRModeType, "MODE");
-#endif
return TRUE;
}
diff --git a/randr/rroutput.c b/randr/rroutput.c
index c1e971ddc..1ecde31a2 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -21,6 +21,7 @@
*/
#include "randrstr.h"
+#include "registry.h"
RESTYPE RROutputType;
@@ -420,9 +421,7 @@ RROutputInit (void)
RROutputType = CreateNewResourceType (RROutputDestroyResource);
if (!RROutputType)
return FALSE;
-#ifdef XResExtension
- RegisterResourceName (RROutputType, "OUTPUT");
-#endif
+ RegisterResourceName (RROutputType, "OUTPUT");
return TRUE;
}
diff --git a/record/record.c b/record/record.c
index f580f643e..debe3c472 100644
--- a/record/record.c
+++ b/record/record.c
@@ -164,13 +164,13 @@ typedef struct {
ProcFunctionPtr recordVector[256];
} RecordClientPrivateRec, *RecordClientPrivatePtr;
-static int RecordClientPrivateIndex;
+static DevPrivateKey RecordClientPrivateKey = &RecordClientPrivateKey;
/* RecordClientPrivatePtr RecordClientPrivate(ClientPtr)
* gets the client private of the given client. Syntactic sugar.
*/
#define RecordClientPrivate(_pClient) (RecordClientPrivatePtr) \
- ((_pClient)->devPrivates[RecordClientPrivateIndex].ptr)
+ dixLookupPrivate(&(_pClient)->devPrivates, RecordClientPrivateKey)
/***************************************************************************/
@@ -982,8 +982,8 @@ RecordInstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
memcpy(pClientPriv->recordVector, pClient->requestVector,
sizeof (pClientPriv->recordVector));
pClientPriv->originalVector = pClient->requestVector;
- pClient->devPrivates[RecordClientPrivateIndex].ptr =
- (pointer)pClientPriv;
+ dixSetPrivate(&pClient->devPrivates,
+ RecordClientPrivateKey, pClientPriv);
pClient->requestVector = pClientPriv->recordVector;
}
while ((pIter = RecordIterateSet(pRCAP->pRequestMajorOpSet,
@@ -1096,7 +1096,8 @@ RecordUninstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
if (!otherRCAPwantsProcVector)
{ /* nobody needs it, so free it */
pClient->requestVector = pClientPriv->originalVector;
- pClient->devPrivates[RecordClientPrivateIndex].ptr = NULL;
+ dixSetPrivate(&pClient->devPrivates,
+ RecordClientPrivateKey, NULL);
xfree(pClientPriv);
}
} /* end if this RCAP specifies any requests */
@@ -2948,10 +2949,6 @@ RecordExtensionInit(void)
if (!RTContext)
return;
- RecordClientPrivateIndex = AllocateClientPrivateIndex();
- if (!AllocateClientPrivate(RecordClientPrivateIndex, 0))
- return;
-
ppAllContexts = NULL;
numContexts = numEnabledContexts = numEnabledRCAPs = 0;
diff --git a/render/animcur.c b/render/animcur.c
index 1f25e79d0..125928931 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -44,6 +44,7 @@
#include "dixfontstr.h"
#include "opaque.h"
#include "picturestr.h"
+#include "xace.h"
typedef struct _AnimCurElt {
CursorPtr pCursor; /* cursor to show */
@@ -87,14 +88,14 @@ static CursorBits animCursorBits = {
empty, empty, 2, 1, 1, 0, 0, 1
};
-static int AnimCurScreenPrivateIndex = -1;
static int AnimCurGeneration;
+static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKey;
#define IsAnimCur(c) ((c)->bits == &animCursorBits)
#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
-#define GetAnimCurScreen(s) ((AnimCurScreenPtr) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr))
-#define GetAnimCurScreenIfSet(s) ((AnimCurScreenPrivateIndex != -1) ? GetAnimCurScreen(s) : NULL)
-#define SetAnimCurScreen(s,p) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr = (pointer) (p))
+#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
+#define GetAnimCurScreenIfSet(s) GetAnimCurScreen(s)
+#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
@@ -128,8 +129,6 @@ AnimCurCloseScreen (int index, ScreenPtr pScreen)
SetAnimCurScreen(pScreen,0);
ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (as);
- if (index == 0)
- AnimCurScreenPrivateIndex = -1;
return ret;
}
@@ -324,9 +323,6 @@ AnimCurInit (ScreenPtr pScreen)
if (AnimCurGeneration != serverGeneration)
{
- AnimCurScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (AnimCurScreenPrivateIndex < 0)
- return FALSE;
AnimCurGeneration = serverGeneration;
animCurState.pCursor = 0;
animCurState.pScreen = 0;
@@ -351,10 +347,10 @@ AnimCurInit (ScreenPtr pScreen)
}
int
-AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor)
+AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid)
{
CursorPtr pCursor;
- int i;
+ int rc, i;
AnimCurPtr ac;
for (i = 0; i < screenInfo.numScreens; i++)
@@ -371,7 +367,6 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
if (!pCursor)
return BadAlloc;
pCursor->bits = &animCursorBits;
- animCursorBits.refcnt++;
pCursor->refcnt = 1;
pCursor->foreRed = cursors[0]->foreRed;
@@ -382,9 +377,22 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp
pCursor->backGreen = cursors[0]->backGreen;
pCursor->backBlue = cursors[0]->backBlue;
+ pCursor->id = cid;
+ pCursor->devPrivates = NULL;
+
+ /* security creation/labeling check */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, pCursor,
+ RT_NONE, NULL, DixCreateAccess);
+ if (rc != Success) {
+ dixFreePrivates(pCursor->devPrivates);
+ xfree(pCursor);
+ return rc;
+ }
+
/*
* Fill in the AnimCurRec
*/
+ animCursorBits.refcnt++;
ac = GetAnimCur (pCursor);
ac->nelt = ncursor;
ac->elts = (AnimCurElt *) (ac + 1);
diff --git a/render/glyph.c b/render/glyph.c
index e1dc0bc99..286e39d63 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -85,220 +85,19 @@ static const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
static GlyphHashRec globalGlyphs[GlyphFormatNum];
-static int globalTotalGlyphPrivateSize = 0;
-
-static int glyphPrivateCount = 0;
-
-void
-ResetGlyphPrivates (void)
-{
- glyphPrivateCount = 0;
-}
-
-int
-AllocateGlyphPrivateIndex (void)
-{
- return glyphPrivateCount++;
-}
-
-Bool
-AllocateGlyphPrivate (ScreenPtr pScreen,
- int index2,
- unsigned amount)
-{
- PictureScreenPtr ps;
- unsigned oldamount;
-
- ps = GetPictureScreenIfSet (pScreen);
- if (!ps)
- return FALSE;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof (DevUnion) - 1)) / sizeof (DevUnion)) *
- sizeof (DevUnion);
-
- if (index2 >= ps->glyphPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *) xrealloc (ps->glyphPrivateSizes,
- (index2 + 1) * sizeof (unsigned));
- if (!nsizes)
- return FALSE;
-
- while (ps->glyphPrivateLen <= index2)
- {
- nsizes[ps->glyphPrivateLen++] = 0;
- ps->totalGlyphPrivateSize += sizeof (DevUnion);
- }
- ps->glyphPrivateSizes = nsizes;
- }
- oldamount = ps->glyphPrivateSizes[index2];
- if (amount > oldamount)
- {
- ps->glyphPrivateSizes[index2] = amount;
- ps->totalGlyphPrivateSize += (amount - oldamount);
- }
- ps->totalGlyphPrivateSize = BitmapBytePad (ps->totalGlyphPrivateSize * 8);
-
- return TRUE;
-}
-
static void
-SetGlyphScreenPrivateOffsets (void)
+FreeGlyphPrivates (GlyphPtr glyph)
{
- PictureScreenPtr ps;
- int offset = 0;
- int i;
+ ScreenPtr pScreen;
+ int i;
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps && ps->totalGlyphPrivateSize)
- {
- ps->glyphPrivateOffset = offset;
- offset += ps->totalGlyphPrivateSize / sizeof (DevUnion);
- }
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+ dixFreePrivates(*GetGlyphPrivatesForScreen(glyph, pScreen));
}
-}
-static void
-SetGlyphPrivatePointers (GlyphPtr glyph)
-{
- PictureScreenPtr ps;
- int i;
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int len;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps && ps->totalGlyphPrivateSize)
- {
- ppriv = glyph->devPrivates + ps->glyphPrivateOffset;
- sizes = ps->glyphPrivateSizes;
- ptr = (char *) (ppriv + ps->glyphPrivateLen);
- for (len = ps->glyphPrivateLen; --len >= 0; ppriv++, sizes++)
- {
- if ((size = *sizes) != 0)
- {
- ppriv->ptr = (pointer) ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer) 0;
- }
- }
- }
-}
-
-static Bool
-ReallocGlobalGlyphPrivate (GlyphPtr glyph)
-{
- PictureScreenPtr ps;
- DevUnion *devPrivates;
- char *ptr;
- int i;
-
- devPrivates = xalloc (globalTotalGlyphPrivateSize);
- if (!devPrivates)
- return FALSE;
-
- ptr = (char *) devPrivates;
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps && ps->totalGlyphPrivateSize)
- {
- if (ps->glyphPrivateOffset != -1)
- {
- memcpy (ptr, glyph->devPrivates + ps->glyphPrivateOffset,
- ps->totalGlyphPrivateSize);
- }
- else if (ps->totalGlyphPrivateSize)
- {
- memset (ptr, 0, ps->totalGlyphPrivateSize);
- }
-
- ptr += ps->totalGlyphPrivateSize;
- }
- }
-
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
-
- glyph->devPrivates = devPrivates;
-
- return TRUE;
-}
-
-Bool
-GlyphInit (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen (pScreen);
-
- ps->totalGlyphPrivateSize = 0;
- ps->glyphPrivateSizes = 0;
- ps->glyphPrivateLen = 0;
- ps->glyphPrivateOffset = -1;
-
- return TRUE;
-}
-
-Bool
-GlyphFinishInit (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen (pScreen);
-
- if (ps->totalGlyphPrivateSize)
- {
- GlyphPtr glyph;
- int fdepth, i;
-
- globalTotalGlyphPrivateSize += ps->totalGlyphPrivateSize;
-
- for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
- {
- if (!globalGlyphs[fdepth].hashSet)
- continue;
-
- for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
- glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- if (!ReallocGlobalGlyphPrivate (glyph))
- return FALSE;
- }
- }
- }
-
- SetGlyphScreenPrivateOffsets ();
-
- for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
- {
- if (!globalGlyphs[fdepth].hashSet)
- continue;
-
- for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
- glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- SetGlyphPrivatePointers (glyph);
-
- if (!(*ps->RealizeGlyph) (pScreen, glyph))
- return FALSE;
- }
- }
- }
- }
- else
- ps->glyphPrivateOffset = 0;
-
- return TRUE;
+ dixFreePrivates(glyph->devPrivates);
+ glyph->devPrivates = NULL;
}
void
@@ -308,8 +107,6 @@ GlyphUninit (ScreenPtr pScreen)
GlyphPtr glyph;
int fdepth, i;
- globalTotalGlyphPrivateSize -= ps->totalGlyphPrivateSize;
-
for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
{
if (!globalGlyphs[fdepth].hashSet)
@@ -321,43 +118,19 @@ GlyphUninit (ScreenPtr pScreen)
if (glyph && glyph != DeletedGlyph)
{
(*ps->UnrealizeGlyph) (pScreen, glyph);
-
- if (globalTotalGlyphPrivateSize)
- {
- if (!ReallocGlobalGlyphPrivate (glyph))
- return;
- }
- else
- {
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
- glyph->devPrivates = NULL;
- }
+ FreeGlyphPrivates(glyph);
}
}
}
- if (globalTotalGlyphPrivateSize)
- SetGlyphScreenPrivateOffsets ();
-
for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
{
if (!globalGlyphs[fdepth].hashSet)
continue;
for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- if (globalTotalGlyphPrivateSize)
- SetGlyphPrivatePointers (glyph);
- }
- }
}
-
- if (ps->glyphPrivateSizes)
- xfree (ps->glyphPrivateSizes);
}
GlyphHashSetPtr
@@ -371,50 +144,6 @@ FindGlyphHashSet (CARD32 filled)
return 0;
}
-static int _GlyphSetPrivateAllocateIndex = 0;
-
-int
-AllocateGlyphSetPrivateIndex (void)
-{
- return _GlyphSetPrivateAllocateIndex++;
-}
-
-void
-ResetGlyphSetPrivateIndex (void)
-{
- _GlyphSetPrivateAllocateIndex = 0;
-}
-
-Bool
-_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr)
-{
- pointer *new;
-
- if (n > glyphSet->maxPrivate) {
- if (glyphSet->devPrivates &&
- glyphSet->devPrivates != (pointer)(&glyphSet[1])) {
- new = (pointer *) xrealloc (glyphSet->devPrivates,
- (n + 1) * sizeof (pointer));
- if (!new)
- return FALSE;
- } else {
- new = (pointer *) xalloc ((n + 1) * sizeof (pointer));
- if (!new)
- return FALSE;
- if (glyphSet->devPrivates)
- memcpy (new,
- glyphSet->devPrivates,
- (glyphSet->maxPrivate + 1) * sizeof (pointer));
- }
- glyphSet->devPrivates = new;
- /* Zero out new, uninitialize privates */
- while (++glyphSet->maxPrivate < n)
- glyphSet->devPrivates[glyphSet->maxPrivate] = (pointer)0;
- }
- glyphSet->devPrivates[n] = ptr;
- return TRUE;
-}
-
GlyphRefPtr
FindGlyphRef (GlyphHashPtr hash,
CARD32 signature,
@@ -582,8 +311,7 @@ FreeGlyph (GlyphPtr glyph, int format)
(*ps->UnrealizeGlyph) (pScreen, glyph);
}
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+ FreeGlyphPrivates(glyph);
xfree (glyph);
}
}
@@ -610,8 +338,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
if (ps)
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+ FreeGlyphPrivates(glyph);
xfree (glyph);
glyph = gr->glyph;
}
@@ -678,16 +405,7 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
glyph->refcnt = 0;
glyph->size = size + sizeof (xGlyphInfo);
glyph->info = *gi;
-
- if (globalTotalGlyphPrivateSize)
- {
- glyph->devPrivates = xalloc (globalTotalGlyphPrivateSize);
- if (!glyph->devPrivates)
- return 0;
-
- SetGlyphPrivatePointers (glyph);
- } else
- glyph->devPrivates = NULL;
+ glyph->devPrivates = NULL;
for (i = 0; i < screenInfo.numScreens; i++)
{
@@ -709,9 +427,8 @@ bail:
if (ps)
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
-
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+
+ FreeGlyphPrivates(glyph);
xfree (glyph);
return 0;
}
@@ -790,15 +507,11 @@ AllocateGlyphSet (int fdepth, PictFormatPtr format)
return FALSE;
}
- size = (sizeof (GlyphSetRec) +
- (sizeof (pointer) * _GlyphSetPrivateAllocateIndex));
+ size = sizeof (GlyphSetRec);
glyphSet = xalloc (size);
if (!glyphSet)
return FALSE;
bzero((char *)glyphSet, size);
- glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1;
- if (_GlyphSetPrivateAllocateIndex)
- glyphSet->devPrivates = (pointer)(&glyphSet[1]);
if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
{
@@ -838,11 +551,7 @@ FreeGlyphSet (pointer value,
else
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
xfree (table);
-
- if (glyphSet->devPrivates &&
- glyphSet->devPrivates != (pointer)(&glyphSet[1]))
- xfree(glyphSet->devPrivates);
-
+ dixFreePrivates(glyphSet->devPrivates);
xfree (glyphSet);
}
return Success;
diff --git a/render/glyphstr.h b/render/glyphstr.h
index c6ab5aa11..67b21fe63 100644
--- a/render/glyphstr.h
+++ b/render/glyphstr.h
@@ -30,6 +30,7 @@
#include "screenint.h"
#include "regionstr.h"
#include "miscstruct.h"
+#include "privates.h"
#define GlyphFormat1 0
#define GlyphFormat4 1
@@ -40,7 +41,7 @@
typedef struct _Glyph {
CARD32 refcnt;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
unsigned char sha1[20];
CARD32 size; /* info + bitmap */
xGlyphInfo info;
@@ -74,18 +75,14 @@ typedef struct _GlyphSet {
int fdepth;
GlyphHashRec hash;
int maxPrivate;
- pointer *devPrivates;
+ PrivateRec *devPrivates;
} GlyphSetRec, *GlyphSetPtr;
-#define GlyphSetGetPrivate(pGlyphSet,n) \
- ((n) > (pGlyphSet)->maxPrivate ? \
- (pointer) 0 : \
- (pGlyphSet)->devPrivates[n])
+#define GlyphSetGetPrivate(pGlyphSet,k) \
+ dixLookupPrivate(&(pGlyphSet)->devPrivates, k)
-#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \
- ((n) > (pGlyphSet)->maxPrivate ? \
- _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \
- ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE))
+#define GlyphSetSetPrivate(pGlyphSet,k,ptr) \
+ dixSetPrivate(&(pGlyphSet)->devPrivates, k, ptr)
typedef struct _GlyphList {
INT16 xOff;
@@ -97,32 +94,6 @@ typedef struct _GlyphList {
GlyphHashSetPtr
FindGlyphHashSet (CARD32 filled);
-int
-AllocateGlyphSetPrivateIndex (void);
-
-void
-ResetGlyphSetPrivateIndex (void);
-
-Bool
-_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr);
-
-void
-ResetGlyphPrivates (void);
-
-int
-AllocateGlyphPrivateIndex (void);
-
-Bool
-AllocateGlyphPrivate (ScreenPtr pScreen,
- int index2,
- unsigned amount);
-
-Bool
-GlyphInit (ScreenPtr pScreen);
-
-Bool
-GlyphFinishInit (ScreenPtr pScreen);
-
void
GlyphUninit (ScreenPtr pScreen);
diff --git a/render/mirect.c b/render/mirect.c
index 464df51c1..38f4faf67 100644
--- a/render/mirect.c
+++ b/render/mirect.c
@@ -158,7 +158,7 @@ miCompositeRects (CARD8 op,
tmpval[0] = xTrue;
pSrc = CreatePicture (0, &pPixmap->drawable, rgbaFormat,
- CPRepeat, tmpval, 0, &error);
+ CPRepeat, tmpval, serverClient, &error);
if (!pSrc)
goto bail4;
diff --git a/render/picture.c b/render/picture.c
index a7e40f994..35e2a28b3 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -40,66 +40,17 @@
#include "gcstruct.h"
#include "servermd.h"
#include "picturestr.h"
+#include "xace.h"
+#include "registry.h"
-_X_EXPORT int PictureScreenPrivateIndex = -1;
-int PictureWindowPrivateIndex;
+_X_EXPORT DevPrivateKey PictureScreenPrivateKey = &PictureScreenPrivateKey;
+DevPrivateKey PictureWindowPrivateKey = &PictureWindowPrivateKey;
static int PictureGeneration;
RESTYPE PictureType;
RESTYPE PictFormatType;
RESTYPE GlyphSetType;
int PictureCmapPolicy = PictureCmapPolicyDefault;
-/* Picture Private machinery */
-
-static int picturePrivateCount;
-
-void
-ResetPicturePrivateIndex (void)
-{
- picturePrivateCount = 0;
-}
-
-int
-AllocatePicturePrivateIndex (void)
-{
- return picturePrivateCount++;
-}
-
-Bool
-AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- unsigned int oldamount;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
-
- if (index2 >= ps->PicturePrivateLen)
- {
- unsigned int *nsizes;
-
- nsizes = (unsigned int *)xrealloc(ps->PicturePrivateSizes,
- (index2 + 1) * sizeof(unsigned int));
- if (!nsizes)
- return FALSE;
- while (ps->PicturePrivateLen <= index2)
- {
- nsizes[ps->PicturePrivateLen++] = 0;
- ps->totalPictureSize += sizeof(DevUnion);
- }
- ps->PicturePrivateSizes = nsizes;
- }
- oldamount = ps->PicturePrivateSizes[index2];
- if (amount > oldamount)
- {
- ps->PicturePrivateSizes[index2] = amount;
- ps->totalPictureSize += (amount - oldamount);
- }
-
- return TRUE;
-}
-
-
Bool
PictureDestroyWindow (WindowPtr pWindow)
{
@@ -137,8 +88,6 @@ PictureCloseScreen (int index, ScreenPtr pScreen)
(*ps->CloseIndexed) (pScreen, &ps->formats[n]);
GlyphUninit (pScreen);
SetPictureScreen(pScreen, 0);
- if (ps->PicturePrivateSizes)
- xfree (ps->PicturePrivateSizes);
xfree (ps->formats);
xfree (ps);
return ret;
@@ -497,8 +446,6 @@ PictureFinishInit (void)
for (s = 0; s < screenInfo.numScreens; s++)
{
- if (!GlyphFinishInit (screenInfo.screens[s]))
- return FALSE;
if (!PictureInitIndexedFormats (screenInfo.screens[s]))
return FALSE;
(void) AnimCurInit (screenInfo.screens[s]);
@@ -637,20 +584,11 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
GlyphSetType = CreateNewResourceType (FreeGlyphSet);
if (!GlyphSetType)
return FALSE;
- PictureScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (PictureScreenPrivateIndex < 0)
- return FALSE;
- PictureWindowPrivateIndex = AllocateWindowPrivateIndex();
PictureGeneration = serverGeneration;
-#ifdef XResExtension
RegisterResourceName (PictureType, "PICTURE");
RegisterResourceName (PictFormatType, "PICTFORMAT");
RegisterResourceName (GlyphSetType, "GLYPHSET");
-#endif
}
- if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0))
- return FALSE;
-
if (!formats)
{
formats = PictureCreateDefaultFormats (pScreen, &nformats);
@@ -697,18 +635,7 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
return FALSE;
}
SetPictureScreen(pScreen, ps);
- if (!GlyphInit (pScreen))
- {
- SetPictureScreen(pScreen, 0);
- xfree (formats);
- xfree (ps);
- return FALSE;
- }
- ps->totalPictureSize = sizeof (PictureRec);
- ps->PicturePrivateSizes = 0;
- ps->PicturePrivateLen = 0;
-
ps->formats = formats;
ps->fallback = formats;
ps->nformats = nformats;
@@ -774,37 +701,6 @@ SetPictureToDefaults (PicturePtr pPicture)
}
PicturePtr
-AllocatePicture (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- PicturePtr pPicture;
- char *ptr;
- DevUnion *ppriv;
- unsigned int *sizes;
- unsigned int size;
- int i;
-
- pPicture = (PicturePtr) xalloc (ps->totalPictureSize);
- if (!pPicture)
- return 0;
- ppriv = (DevUnion *)(pPicture + 1);
- pPicture->devPrivates = ppriv;
- sizes = ps->PicturePrivateSizes;
- ptr = (char *)(ppriv + ps->PicturePrivateLen);
- for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
- return pPicture;
-}
-
-PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
@@ -816,7 +712,7 @@ CreatePicture (Picture pid,
PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
- pPicture = AllocatePicture (pDrawable->pScreen);
+ pPicture = (PicturePtr)xalloc(sizeof(PictureRec));
if (!pPicture)
{
*error = BadAlloc;
@@ -827,6 +723,14 @@ CreatePicture (Picture pid,
pPicture->pDrawable = pDrawable;
pPicture->pFormat = pFormat;
pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24);
+ pPicture->devPrivates = NULL;
+
+ /* security creation/labeling check */
+ *error = XaceHook(XACE_RESOURCE_ACCESS, client, pid, PictureType, pPicture,
+ RT_PIXMAP, pDrawable, DixCreateAccess|DixSetAttrAccess);
+ if (*error != Success)
+ goto out;
+
if (pDrawable->type == DRAWABLE_PIXMAP)
{
++((PixmapPtr)pDrawable)->refcnt;
@@ -846,6 +750,7 @@ CreatePicture (Picture pid,
*error = Success;
if (*error == Success)
*error = (*ps->CreatePicture) (pPicture);
+out:
if (*error != Success)
{
FreePicture (pPicture, (XID) 0);
@@ -1163,14 +1068,13 @@ ChangePicture (PicturePtr pPicture,
pAlpha = 0;
else
{
- pAlpha = (PicturePtr) SecurityLookupIDByType(client,
- pid,
- PictureType,
- DixWriteAccess|DixReadAccess);
- if (!pAlpha)
+ error = dixLookupResource((pointer *)&pAlpha, pid,
+ PictureType, client,
+ DixReadAccess);
+ if (error != Success)
{
client->errorValue = pid;
- error = BadPixmap;
+ error = (error == BadValue) ? BadPixmap : error;
break;
}
if (pAlpha->pDrawable == NULL ||
@@ -1225,14 +1129,13 @@ ChangePicture (PicturePtr pPicture,
else
{
clipType = CT_PIXMAP;
- pPixmap = (PixmapPtr)SecurityLookupIDByType(client,
- pid,
- RT_PIXMAP,
- DixReadAccess);
- if (!pPixmap)
+ error = dixLookupResource((pointer *)&pPixmap, pid,
+ RT_PIXMAP, client,
+ DixReadAccess);
+ if (error != Success)
{
client->errorValue = pid;
- error = BadPixmap;
+ error = (error == BadValue) ? BadPixmap : error;
break;
}
}
@@ -1607,7 +1510,8 @@ FreePicture (pointer value,
WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
PicturePtr *pPrev;
- for (pPrev = (PicturePtr *) &((pWindow)->devPrivates[PictureWindowPrivateIndex].ptr);
+ for (pPrev = (PicturePtr *)dixLookupPrivateAddr
+ (&pWindow->devPrivates, PictureWindowPrivateKey);
*pPrev;
pPrev = &(*pPrev)->pNext)
{
@@ -1623,6 +1527,7 @@ FreePicture (pointer value,
(*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
}
}
+ dixFreePrivates(pPicture->devPrivates);
xfree (pPicture);
}
return Success;
diff --git a/render/picture.h b/render/picture.h
index e8a098cd9..045b29944 100644
--- a/render/picture.h
+++ b/render/picture.h
@@ -163,8 +163,8 @@ extern int PictureCmapPolicy;
int PictureParseCmapPolicy (const char *name);
-extern int RenderErrBase;
-extern int RenderClientPrivateIndex;
+extern int RenderErrBase;
+extern DevPrivateKey RenderClientPrivateKey;
/* Fixed point updates from Carl Worth, USC, Information Sciences Institute */
diff --git a/render/picturestr.h b/render/picturestr.h
index ba165a411..acd15c7fe 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -27,6 +27,7 @@
#include "scrnintstr.h"
#include "glyphstr.h"
#include "resource.h"
+#include "privates.h"
typedef struct _DirectFormat {
CARD16 red, redMask;
@@ -173,7 +174,7 @@ typedef struct _Picture {
RegionPtr pCompositeClip;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
PictTransform *transform;
@@ -328,10 +329,6 @@ typedef void (*UnrealizeGlyphProcPtr) (ScreenPtr pScreen,
GlyphPtr glyph);
typedef struct _PictureScreen {
- int totalPictureSize;
- unsigned int *PicturePrivateSizes;
- int PicturePrivateLen;
-
PictFormatPtr formats;
PictFormatPtr fallback;
int nformats;
@@ -389,30 +386,25 @@ typedef struct _PictureScreen {
AddTrapsProcPtr AddTraps;
- int totalGlyphPrivateSize;
- unsigned int *glyphPrivateSizes;
- int glyphPrivateLen;
- int glyphPrivateOffset;
-
RealizeGlyphProcPtr RealizeGlyph;
UnrealizeGlyphProcPtr UnrealizeGlyph;
} PictureScreenRec, *PictureScreenPtr;
-extern int PictureScreenPrivateIndex;
-extern int PictureWindowPrivateIndex;
+extern DevPrivateKey PictureScreenPrivateKey;
+extern DevPrivateKey PictureWindowPrivateKey;
extern RESTYPE PictureType;
extern RESTYPE PictFormatType;
extern RESTYPE GlyphSetType;
-#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
-#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
-#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (pointer) (p))
-#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
-#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (pointer) (p))
+#define GetPictureScreen(s) ((PictureScreenPtr)dixLookupPrivate(&(s)->devPrivates, PictureScreenPrivateKey))
+#define GetPictureScreenIfSet(s) GetPictureScreen(s)
+#define SetPictureScreen(s,p) dixSetPrivate(&(s)->devPrivates, PictureScreenPrivateKey, p)
+#define GetPictureWindow(w) ((PicturePtr)dixLookupPrivate(&(w)->devPrivates, PictureWindowPrivateKey))
+#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p)
-#define GetGlyphPrivatesForScreen(glyph, s) \
- ((glyph)->devPrivates + (GetPictureScreen (s))->glyphPrivateOffset)
+#define GetGlyphPrivatesForScreen(glyph, s) \
+ ((PrivateRec **)dixLookupPrivateAddr(&(glyph)->devPrivates, s))
#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
@@ -430,15 +422,6 @@ extern RESTYPE GlyphSetType;
} \
} \
-void
-ResetPicturePrivateIndex (void);
-
-int
-AllocatePicturePrivateIndex (void);
-
-Bool
-AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount);
-
Bool
PictureDestroyWindow (WindowPtr pWindow);
@@ -502,9 +485,6 @@ void
SetPictureToDefaults (PicturePtr pPicture);
PicturePtr
-AllocatePicture (ScreenPtr pScreen);
-
-PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
@@ -644,7 +624,7 @@ Bool
AnimCurInit (ScreenPtr pScreen);
int
-AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor);
+AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor, ClientPtr client, XID cid);
void
AddTraps (PicturePtr pPicture,
diff --git a/render/render.c b/render/render.c
index b432406f7..f03f54a2b 100644
--- a/render/render.c
+++ b/render/render.c
@@ -46,6 +46,7 @@
#include "glyphstr.h"
#include <X11/Xfuncproto.h>
#include "cursorstr.h"
+#include "xace.h"
#if HAVE_STDINT_H
#include <stdint.h>
@@ -213,14 +214,14 @@ static void
RenderResetProc (ExtensionEntry *extEntry);
int RenderErrBase;
-int RenderClientPrivateIndex;
+DevPrivateKey RenderClientPrivateKey;
typedef struct _RenderClient {
int major_version;
int minor_version;
} RenderClientRec, *RenderClientPtr;
-#define GetRenderClient(pClient) ((RenderClientPtr) (pClient)->devPrivates[RenderClientPrivateIndex].ptr)
+#define GetRenderClient(pClient) ((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RenderClientPrivateKey))
static void
RenderClientCallback (CallbackListPtr *list,
@@ -244,9 +245,7 @@ RenderExtensionInit (void)
return;
if (!PictureFinishInit ())
return;
- RenderClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (RenderClientPrivateIndex,
- sizeof (RenderClientRec)))
+ if (!dixRequestPrivate(RenderClientPrivateKey, sizeof(RenderClientRec)))
return;
if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0))
return;
@@ -262,8 +261,6 @@ RenderExtensionInit (void)
static void
RenderResetProc (ExtensionEntry *extEntry)
{
- ResetPicturePrivateIndex();
- ResetGlyphSetPrivateIndex();
}
static int
@@ -601,7 +598,7 @@ ProcRenderCreatePicture (ClientPtr client)
LEGAL_NEW_RESOURCE(stuff->pid, client);
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixWriteAccess);
+ DixReadAccess|DixAddAccess);
if (rc != Success)
return rc;
@@ -642,7 +639,7 @@ ProcRenderChangePicture (ClientPtr client)
int len;
REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
- VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess,
+ VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
len = client->req_len - (sizeof(xRenderChangePictureReq) >> 2);
@@ -662,7 +659,7 @@ ProcRenderSetPictureClipRectangles (ClientPtr client)
int result;
REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq);
- VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess,
+ VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
if (!pPicture->pDrawable)
return BadDrawable;
@@ -961,7 +958,7 @@ ProcRenderCreateGlyphSet (ClientPtr client)
{
GlyphSetPtr glyphSet;
PictFormatPtr format;
- int f;
+ int rc, f;
REQUEST(xRenderCreateGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq);
@@ -1000,6 +997,11 @@ ProcRenderCreateGlyphSet (ClientPtr client)
glyphSet = AllocateGlyphSet (f, format);
if (!glyphSet)
return BadAlloc;
+ /* security creation/labeling check */
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->gsid, GlyphSetType,
+ glyphSet, RT_NONE, NULL, DixCreateAccess);
+ if (rc != Success)
+ return rc;
if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
return BadAlloc;
return Success;
@@ -1009,20 +1011,19 @@ static int
ProcRenderReferenceGlyphSet (ClientPtr client)
{
GlyphSetPtr glyphSet;
+ int rc;
REQUEST(xRenderReferenceGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq);
LEGAL_NEW_RESOURCE(stuff->gsid, client);
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->existing,
- GlyphSetType,
- DixWriteAccess);
- if (!glyphSet)
+ rc = dixLookupResource((pointer *)&glyphSet, stuff->existing, GlyphSetType,
+ client, DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->existing;
- return RenderErrBase + BadGlyphSet;
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
glyphSet->refcnt++;
if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet))
@@ -1037,17 +1038,16 @@ static int
ProcRenderFreeGlyphSet (ClientPtr client)
{
GlyphSetPtr glyphSet;
+ int rc;
REQUEST(xRenderFreeGlyphSetReq);
REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->glyphset,
- GlyphSetType,
- DixDestroyAccess);
- if (!glyphSet)
+ rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
+ client, DixDestroyAccess);
+ if (rc != Success)
{
client->errorValue = stuff->glyphset;
- return RenderErrBase + BadGlyphSet;
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
FreeResource (stuff->glyphset, RT_NONE);
return client->noClientException;
@@ -1074,23 +1074,22 @@ ProcRenderAddGlyphs (ClientPtr client)
xGlyphInfo *gi;
CARD8 *bits;
int size;
- int err = BadAlloc;
+ int err;
int i, screen;
PicturePtr pSrc = NULL, pDst = NULL;
PixmapPtr pSrcPix = NULL, pDstPix = NULL;
CARD32 component_alpha;
REQUEST_AT_LEAST_SIZE(xRenderAddGlyphsReq);
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->glyphset,
- GlyphSetType,
- DixWriteAccess);
- if (!glyphSet)
+ err = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
+ client, DixAddAccess);
+ if (err != Success)
{
client->errorValue = stuff->glyphset;
- return RenderErrBase + BadGlyphSet;
+ return (err == BadValue) ? RenderErrBase + BadGlyphSet : err;
}
+ err = BadAlloc;
nglyphs = stuff->nglyphs;
if (nglyphs > UINT32_MAX / sizeof(GlyphNewRec))
return BadAlloc;
@@ -1260,19 +1259,17 @@ ProcRenderFreeGlyphs (ClientPtr client)
{
REQUEST(xRenderFreeGlyphsReq);
GlyphSetPtr glyphSet;
- int nglyph;
+ int rc, nglyph;
CARD32 *gids;
CARD32 glyph;
REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
- glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
- stuff->glyphset,
- GlyphSetType,
- DixWriteAccess);
- if (!glyphSet)
+ rc = dixLookupResource((pointer *)&glyphSet, stuff->glyphset, GlyphSetType,
+ client, DixRemoveAccess);
+ if (rc != Success)
{
client->errorValue = stuff->glyphset;
- return RenderErrBase + BadGlyphSet;
+ return (rc == BadValue) ? RenderErrBase + BadGlyphSet : rc;
}
nglyph = ((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)) >> 2;
gids = (CARD32 *) (stuff + 1);
@@ -1349,7 +1346,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
stuff->glyphset,
GlyphSetType,
- DixReadAccess);
+ DixUseAccess);
if (!glyphSet)
{
client->errorValue = stuff->glyphset;
@@ -1411,7 +1408,7 @@ ProcRenderCompositeGlyphs (ClientPtr client)
glyphSet = (GlyphSetPtr) SecurityLookupIDByType (client,
gs,
GlyphSetType,
- DixReadAccess);
+ DixUseAccess);
if (!glyphSet)
{
client->errorValue = gs;
@@ -1553,7 +1550,7 @@ ProcRenderCreateCursor (ClientPtr client)
CursorMetricRec cm;
CursorPtr pCursor;
CARD32 twocolor[3];
- int ncolor;
+ int rc, ncolor;
REQUEST_SIZE_MATCH (xRenderCreateCursorReq);
LEGAL_NEW_RESOURCE(stuff->cid, client);
@@ -1721,16 +1718,20 @@ ProcRenderCreateCursor (ClientPtr client)
cm.height = height;
cm.xhot = stuff->x;
cm.yhot = stuff->y;
- pCursor = AllocCursorARGB (srcbits, mskbits, argbbits, &cm,
- GetColor(twocolor[0], 16),
- GetColor(twocolor[0], 8),
- GetColor(twocolor[0], 0),
- GetColor(twocolor[1], 16),
- GetColor(twocolor[1], 8),
- GetColor(twocolor[1], 0));
- if (pCursor && AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
- return (client->noClientException);
- return BadAlloc;
+ rc = AllocARGBCursor(srcbits, mskbits, argbbits, &cm,
+ GetColor(twocolor[0], 16),
+ GetColor(twocolor[0], 8),
+ GetColor(twocolor[0], 0),
+ GetColor(twocolor[1], 16),
+ GetColor(twocolor[1], 8),
+ GetColor(twocolor[1], 0),
+ &pCursor, client, stuff->cid);
+ if (rc != Success)
+ return rc;
+ if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor))
+ return BadAlloc;
+
+ return client->noClientException;
}
static int
@@ -1741,7 +1742,7 @@ ProcRenderSetPictureTransform (ClientPtr client)
int result;
REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq);
- VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess,
+ VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
result = SetPictureTransform (pPicture, (PictTransform *) &stuff->transform);
if (client->noClientException != Success)
@@ -1766,7 +1767,7 @@ ProcRenderQueryFilters (ClientPtr client)
REQUEST_SIZE_MATCH(xRenderQueryFiltersReq);
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
+ DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -1871,7 +1872,7 @@ ProcRenderSetPictureFilter (ClientPtr client)
char *name;
REQUEST_AT_LEAST_SIZE (xRenderSetPictureFilterReq);
- VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess,
+ VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
name = (char *) (stuff + 1);
params = (xFixed *) (name + ((stuff->nbytes + 3) & ~3));
@@ -1915,7 +1916,8 @@ ProcRenderCreateAnimCursor (ClientPtr client)
deltas[i] = elt->delay;
elt++;
}
- ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor);
+ ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor, client,
+ stuff->cid);
xfree (cursors);
if (ret != Success)
return ret;
@@ -1961,6 +1963,11 @@ static int ProcRenderCreateSolidFill(ClientPtr client)
pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error);
if (!pPicture)
return error;
+ /* security creation/labeling check */
+ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
+ pPicture, RT_NONE, NULL, DixCreateAccess);
+ if (error != Success)
+ return error;
if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
return BadAlloc;
return Success;
@@ -1990,6 +1997,11 @@ static int ProcRenderCreateLinearGradient (ClientPtr client)
stuff->nStops, stops, colors, &error);
if (!pPicture)
return error;
+ /* security creation/labeling check */
+ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
+ pPicture, RT_NONE, NULL, DixCreateAccess);
+ if (error != Success)
+ return error;
if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
return BadAlloc;
return Success;
@@ -2020,6 +2032,11 @@ static int ProcRenderCreateRadialGradient (ClientPtr client)
stuff->nStops, stops, colors, &error);
if (!pPicture)
return error;
+ /* security creation/labeling check */
+ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
+ pPicture, RT_NONE, NULL, DixCreateAccess);
+ if (error != Success)
+ return error;
if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
return BadAlloc;
return Success;
@@ -2049,6 +2066,11 @@ static int ProcRenderCreateConicalGradient (ClientPtr client)
stuff->nStops, stops, colors, &error);
if (!pPicture)
return error;
+ /* security creation/labeling check */
+ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
+ pPicture, RT_NONE, NULL, DixCreateAccess);
+ if (error != Success)
+ return error;
if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
return BadAlloc;
return Success;
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 401c403c8..1d122faea 100755
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -51,12 +51,12 @@
#include "servermd.h"
#include "inputstr.h"
#include "windowstr.h"
+#include "xace.h"
static RESTYPE CursorClientType;
static RESTYPE CursorHideCountType;
static RESTYPE CursorWindowType;
-static int CursorScreenPrivateIndex = -1;
-static int CursorGeneration;
+static DevPrivateKey CursorScreenPrivateKey = &CursorScreenPrivateKey;
static CursorPtr CursorCurrent;
static CursorPtr pInvisibleCursor = NULL;
@@ -113,9 +113,9 @@ typedef struct _CursorScreen {
CursorHideCountPtr pCursorHideCounts;
} CursorScreenRec, *CursorScreenPtr;
-#define GetCursorScreen(s) ((CursorScreenPtr) ((s)->devPrivates[CursorScreenPrivateIndex].ptr))
-#define GetCursorScreenIfSet(s) ((CursorScreenPrivateIndex != -1) ? GetCursorScreen(s) : NULL)
-#define SetCursorScreen(s,p) ((s)->devPrivates[CursorScreenPrivateIndex].ptr = (pointer) (p))
+#define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey))
+#define GetCursorScreenIfSet(s) GetCursorScreen(s)
+#define SetCursorScreen(s,p) dixSetPrivate(&(s)->devPrivates, CursorScreenPrivateKey, p)
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
@@ -171,8 +171,6 @@ CursorCloseScreen (int index, ScreenPtr pScreen)
deleteCursorHideCountsForScreen(pScreen);
ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (cs);
- if (index == 0)
- CursorScreenPrivateIndex = -1;
return ret;
}
@@ -241,7 +239,7 @@ ProcXFixesSelectCursorInput (ClientPtr client)
int rc;
REQUEST_SIZE_MATCH (xXFixesSelectCursorInputReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
if (stuff->eventMask & ~CursorAllEvents)
@@ -346,14 +344,16 @@ ProcXFixesGetCursorImage (ClientPtr client)
xXFixesGetCursorImageReply *rep;
CursorPtr pCursor;
CARD32 *image;
- int npixels;
- int width, height;
- int x, y;
+ int npixels, width, height, rc, x, y;
REQUEST_SIZE_MATCH(xXFixesGetCursorImageReq);
pCursor = CursorCurrent;
if (!pCursor)
return BadCursor;
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, RT_CURSOR,
+ pCursor, RT_NONE, NULL, DixReadAccess);
+ if (rc != Success)
+ return rc;
GetSpritePosition (&x, &y);
width = pCursor->bits->width;
height = pCursor->bits->height;
@@ -414,7 +414,7 @@ ProcXFixesSetCursorName (ClientPtr client)
Atom atom;
REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
- VERIFY_CURSOR(pCursor, stuff->cursor, client, DixWriteAccess);
+ VERIFY_CURSOR(pCursor, stuff->cursor, client, DixSetAttrAccess);
tchar = (char *) &stuff[1];
atom = MakeAtom (tchar, stuff->nbytes, TRUE);
if (atom == BAD_RESOURCE)
@@ -447,7 +447,7 @@ ProcXFixesGetCursorName (ClientPtr client)
int len;
REQUEST_SIZE_MATCH(xXFixesGetCursorNameReq);
- VERIFY_CURSOR(pCursor, stuff->cursor, client, DixReadAccess);
+ VERIFY_CURSOR(pCursor, stuff->cursor, client, DixGetAttrAccess);
if (pCursor->name)
str = NameForAtom (pCursor->name);
else
@@ -496,12 +496,16 @@ ProcXFixesGetCursorImageAndName (ClientPtr client)
char *name;
int nbytes, nbytesRound;
int width, height;
- int x, y;
+ int rc, x, y;
REQUEST_SIZE_MATCH(xXFixesGetCursorImageAndNameReq);
pCursor = CursorCurrent;
if (!pCursor)
return BadCursor;
+ rc = XaceHook(XACE_RESOURCE_ACCESS, client, pCursor->id, RT_CURSOR,
+ pCursor, RT_NONE, NULL, DixReadAccess|DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
GetSpritePosition (&x, &y);
width = pCursor->bits->width;
height = pCursor->bits->height;
@@ -678,8 +682,10 @@ ProcXFixesChangeCursor (ClientPtr client)
REQUEST(xXFixesChangeCursorReq);
REQUEST_SIZE_MATCH(xXFixesChangeCursorReq);
- VERIFY_CURSOR (pSource, stuff->source, client, DixReadAccess);
- VERIFY_CURSOR (pDestination, stuff->destination, client, DixWriteAccess);
+ VERIFY_CURSOR (pSource, stuff->source, client,
+ DixReadAccess|DixGetAttrAccess);
+ VERIFY_CURSOR (pDestination, stuff->destination, client,
+ DixWriteAccess|DixSetAttrAccess);
ReplaceCursor (pSource, TestForCursor, (pointer) pDestination);
return (client->noClientException);
@@ -713,7 +719,8 @@ ProcXFixesChangeCursorByName (ClientPtr client)
REQUEST(xXFixesChangeCursorByNameReq);
REQUEST_FIXED_SIZE(xXFixesChangeCursorByNameReq, stuff->nbytes);
- VERIFY_CURSOR(pSource, stuff->source, client, DixReadAccess);
+ VERIFY_CURSOR(pSource, stuff->source, client,
+ DixReadAccess|DixGetAttrAccess);
tchar = (char *) &stuff[1];
name = MakeAtom (tchar, stuff->nbytes, FALSE);
if (name)
@@ -841,10 +848,11 @@ ProcXFixesHideCursor (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesHideCursorReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin) {
+ ret = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW,
+ client, DixGetAttrAccess);
+ if (ret != Success) {
client->errorValue = stuff->window;
- return BadWindow;
+ return (ret == BadValue) ? BadWindow : ret;
}
/*
@@ -862,6 +870,11 @@ ProcXFixesHideCursor (ClientPtr client)
* This is the first time this client has hid the cursor
* for this screen.
*/
+ ret = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen,
+ DixHideAccess);
+ if (ret != Success)
+ return ret;
+
ret = createCursorHideCount(client, pWin->drawable.pScreen);
if (ret == Success) {
@@ -888,14 +901,16 @@ ProcXFixesShowCursor (ClientPtr client)
{
WindowPtr pWin;
CursorHideCountPtr pChc;
+ int rc;
REQUEST(xXFixesShowCursorReq);
REQUEST_SIZE_MATCH (xXFixesShowCursorReq);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin) {
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW,
+ client, DixGetAttrAccess);
+ if (rc != Success) {
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
/*
@@ -907,6 +922,11 @@ ProcXFixesShowCursor (ClientPtr client)
return BadMatch;
}
+ rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen,
+ DixShowAccess);
+ if (rc != Success)
+ return rc;
+
pChc->hideCount--;
if (pChc->hideCount <= 0) {
FreeResource(pChc->resource, 0);
@@ -980,6 +1000,7 @@ createInvisibleCursor (void)
CursorPtr pCursor;
static unsigned int *psrcbits, *pmaskbits;
CursorMetricRec cm;
+ int rc;
psrcbits = (unsigned int *) xalloc(4);
pmaskbits = (unsigned int *) xalloc(4);
@@ -994,12 +1015,13 @@ createInvisibleCursor (void)
cm.xhot = 0;
cm.yhot = 0;
- pCursor = AllocCursor(
+ rc = AllocARGBCursor(
(unsigned char *)psrcbits,
(unsigned char *)pmaskbits,
- &cm,
+ NULL, &cm,
+ 0, 0, 0,
0, 0, 0,
- 0, 0, 0);
+ &pCursor, serverClient, (XID)0);
return pCursor;
}
@@ -1009,13 +1031,6 @@ XFixesCursorInit (void)
{
int i;
- if (CursorGeneration != serverGeneration)
- {
- CursorScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (CursorScreenPrivateIndex < 0)
- return FALSE;
- CursorGeneration = serverGeneration;
- }
for (i = 0; i < screenInfo.numScreens; i++)
{
ScreenPtr pScreen = screenInfo.screens[i];
diff --git a/xfixes/region.c b/xfixes/region.c
index d4316be78..d90b1e0ff 100755
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -109,18 +109,18 @@ ProcXFixesCreateRegionFromBitmap (ClientPtr client)
{
RegionPtr pRegion;
PixmapPtr pPixmap;
+ int rc;
REQUEST (xXFixesCreateRegionFromBitmapReq);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
- pPixmap = (PixmapPtr) SecurityLookupIDByType (client, stuff->bitmap,
- RT_PIXMAP,
- DixReadAccess);
- if (!pPixmap)
+ rc = dixLookupResource((pointer *)&pPixmap, stuff->bitmap, RT_PIXMAP,
+ client, DixReadAccess);
+ if (rc != Success)
{
client->errorValue = stuff->bitmap;
- return BadPixmap;
+ return (rc == BadValue) ? BadPixmap : rc;
}
if (pPixmap->drawable.depth != 1)
return BadMatch;
@@ -155,15 +155,17 @@ ProcXFixesCreateRegionFromWindow (ClientPtr client)
RegionPtr pRegion;
Bool copy = TRUE;
WindowPtr pWin;
+ int rc;
REQUEST (xXFixesCreateRegionFromWindowReq);
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
- pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->window, RT_WINDOW,
+ client, DixGetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->window;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
switch (stuff->kind) {
case WindowRegionBounding:
@@ -224,7 +226,7 @@ ProcXFixesCreateRegionFromGC (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
- rc = dixLookupGC(&pGC, stuff->gc, client, DixReadAccess);
+ rc = dixLookupGC(&pGC, stuff->gc, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@@ -274,7 +276,7 @@ ProcXFixesCreateRegionFromPicture (ClientPtr client)
REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq);
LEGAL_NEW_RESOURCE (stuff->region, client);
- VERIFY_PICTURE(pPicture, stuff->picture, client, DixReadAccess,
+ VERIFY_PICTURE(pPicture, stuff->picture, client, DixGetAttrAccess,
RenderErrBase + BadPicture);
switch (pPicture->clientClipType) {
@@ -635,7 +637,7 @@ ProcXFixesSetGCClipRegion (ClientPtr client)
REQUEST(xXFixesSetGCClipRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
- rc = dixLookupGC(&pGC, stuff->gc, client, DixWriteAccess);
+ rc = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess);
if (rc != Success)
return rc;
@@ -681,14 +683,16 @@ ProcXFixesSetWindowShapeRegion (ClientPtr client)
ScreenPtr pScreen;
RegionPtr pRegion;
RegionPtr *pDestRegion;
+ int rc;
REQUEST(xXFixesSetWindowShapeRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
- pWin = (WindowPtr) LookupIDByType (stuff->dest, RT_WINDOW);
- if (!pWin)
+ rc = dixLookupResource((pointer *)&pWin, stuff->dest, RT_WINDOW,
+ client, DixSetAttrAccess);
+ if (rc != Success)
{
client->errorValue = stuff->dest;
- return BadWindow;
+ return (rc == BadValue) ? BadWindow : rc;
}
VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixWriteAccess);
pScreen = pWin->drawable.pScreen;
@@ -780,7 +784,7 @@ ProcXFixesSetPictureClipRegion (ClientPtr client)
REQUEST(xXFixesSetPictureClipRegionReq);
REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq);
- VERIFY_PICTURE(pPicture, stuff->picture, client, DixWriteAccess,
+ VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess,
RenderErrBase + BadPicture);
pScreen = pPicture->pDrawable->pScreen;
ps = GetPictureScreen (pScreen);
diff --git a/xfixes/saveset.c b/xfixes/saveset.c
index 8d66843d9..e6e297638 100755
--- a/xfixes/saveset.c
+++ b/xfixes/saveset.c
@@ -35,7 +35,7 @@ ProcXFixesChangeSaveSet(ClientPtr client)
REQUEST(xXFixesChangeSaveSetReq);
REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq);
- result = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ result = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess);
if (result != Success)
return result;
if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
diff --git a/xfixes/select.c b/xfixes/select.c
index c0076801d..2321212ce 100755
--- a/xfixes/select.c
+++ b/xfixes/select.c
@@ -25,6 +25,7 @@
#endif
#include "xfixesint.h"
+#include "xace.h"
static RESTYPE SelectionClientType, SelectionWindowType;
static Bool SelectionCallbackRegistered = FALSE;
@@ -131,8 +132,14 @@ XFixesSelectSelectionInput (ClientPtr pClient,
WindowPtr pWindow,
CARD32 eventMask)
{
+ int rc;
SelectionEventPtr *prev, e;
+ rc = XaceHook(XACE_SELECTION_ACCESS, pClient, selection, NULL,
+ DixGetAttrAccess);
+ if (rc != Success)
+ return rc;
+
for (prev = &selectionEvents; (e = *prev); prev = &e->next)
{
if (e->selection == selection &&
@@ -196,7 +203,7 @@ ProcXFixesSelectSelectionInput (ClientPtr client)
int rc;
REQUEST_SIZE_MATCH (xXFixesSelectSelectionInputReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
if (stuff->eventMask & ~SelectionAllEvents)
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index 32dee8a18..0db49895e 100755
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -56,7 +56,7 @@
static unsigned char XFixesReqCode;
int XFixesEventBase;
int XFixesErrorBase;
-static int XFixesClientPrivateIndex;
+static DevPrivateKey XFixesClientPrivateKey = &XFixesClientPrivateKey;
static int
ProcXFixesQueryVersion(ClientPtr client)
@@ -239,9 +239,7 @@ XFixesExtensionInit(void)
{
ExtensionEntry *extEntry;
- XFixesClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (XFixesClientPrivateIndex,
- sizeof (XFixesClientRec)))
+ if (!dixRequestPrivate(XFixesClientPrivateKey, sizeof (XFixesClientRec)))
return;
if (!AddCallback (&ClientStateCallback, XFixesClientCallback, 0))
return;
diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h
index 48927ae0f..33a3205ed 100755
--- a/xfixes/xfixesint.h
+++ b/xfixes/xfixesint.h
@@ -66,7 +66,7 @@ typedef struct _XFixesClient {
CARD32 minor_version;
} XFixesClientRec, *XFixesClientPtr;
-#define GetXFixesClient(pClient) ((XFixesClientPtr) (pClient)->devPrivates[XFixesClientPrivateIndex].ptr)
+#define GetXFixesClient(pClient) ((XFixesClientPtr)dixLookupPrivate(&(pClient)->devPrivates, XFixesClientPrivateKey))
extern int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr);
diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
index 7e27c5189..5313a1ec5 100644
--- a/xkb/ddxDevBtn.c
+++ b/xkb/ddxDevBtn.c
@@ -53,7 +53,7 @@ deviceValuator * val;
int x,y;
int nAxes, i, count;
- if ((dev==(DeviceIntPtr)LookupPointerDevice())||(!dev->public.on))
+ if (dev == inputInfo.pointer || !dev->public.on)
return;
nAxes = (dev->valuator?dev->valuator->numAxes:0);
diff --git a/xkb/ddxFakeBtn.c b/xkb/ddxFakeBtn.c
index 8144fd2c5..2dad54fea 100644
--- a/xkb/ddxFakeBtn.c
+++ b/xkb/ddxFakeBtn.c
@@ -46,7 +46,7 @@ xEvent ev;
int x,y;
DevicePtr ptr;
- if ((ptr = LookupPointerDevice())==NULL)
+ if ((ptr = (DevicePtr)inputInfo.pointer)==NULL)
return;
GetSpritePosition(&x,&y);
ev.u.u.type = event;
diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c
index 1060afe99..320e0ca33 100644
--- a/xkb/ddxFakeMtn.c
+++ b/xkb/ddxFakeMtn.c
@@ -107,7 +107,7 @@ ScreenPtr pScreen, oldScreen;
oldY= y;
else oldY+= y;
-#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr))
+#define GetScreenPrivate(s) ((miPointerScreenPtr)dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
(*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen)
(&pScreen, &oldX, &oldY);
}
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 2b8b52835..23e1dc76f 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -38,6 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
#include "extnsionst.h"
+#include "xace.h"
#include "xkb.h"
#include <X11/extensions/XI.h>
@@ -45,7 +46,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
int XkbEventBase;
static int XkbErrorBase;
int XkbReqCode;
-static int XkbKeyboardErrorCode;
+ int XkbKeyboardErrorCode;
CARD32 xkbDebugFlags = 0;
static CARD32 xkbDebugCtrls = 0;
@@ -53,19 +54,23 @@ static RESTYPE RT_XKBCLIENT;
/***====================================================================***/
-#define CHK_DEVICE(d,sp,lf) {\
+#define CHK_DEVICE(dev, id, client, access_mode, lf) {\
int why;\
- d = (DeviceIntPtr)lf((sp),&why);\
- if (!dev) {\
- client->errorValue = _XkbErrCode2(why,(sp));\
- return XkbKeyboardErrorCode;\
+ int rc = lf(&(dev), id, client, access_mode, &why);\
+ if (rc != Success) {\
+ client->errorValue = _XkbErrCode2(why, id);\
+ return rc;\
}\
}
-#define CHK_KBD_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupKeyboard)
-#define CHK_LED_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupLedDevice)
-#define CHK_BELL_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupBellDevice)
-#define CHK_ANY_DEVICE(d,sp) CHK_DEVICE(d,sp,_XkbLookupAnyDevice)
+#define CHK_KBD_DEVICE(dev, id, client, mode) \
+ CHK_DEVICE(dev, id, client, mode, _XkbLookupKeyboard)
+#define CHK_LED_DEVICE(dev, id, client, mode) \
+ CHK_DEVICE(dev, id, client, mode, _XkbLookupLedDevice)
+#define CHK_BELL_DEVICE(dev, id, client, mode) \
+ CHK_DEVICE(dev, id, client, mode, _XkbLookupBellDevice)
+#define CHK_ANY_DEVICE(dev, id, client, mode) \
+ CHK_DEVICE(dev, id, client, mode, _XkbLookupAnyDevice)
#define CHK_ATOM_ONLY2(a,ev,er) {\
if (((a)==None)||(!ValidAtom((a)))) {\
@@ -206,7 +211,7 @@ ProcXkbSelectEvents(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_ANY_DEVICE(dev,stuff->deviceSpec);
+ CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess);
if (((stuff->affectWhich&XkbMapNotifyMask)!=0)&&(stuff->affectMap)) {
client->mapNotifyMask&= ~stuff->affectMap;
@@ -351,7 +356,7 @@ ProcXkbBell(ClientPtr client)
REQUEST(xkbBellReq);
DeviceIntPtr dev;
WindowPtr pWin;
- int base;
+ int rc, base;
int newPercent,oldPitch,oldDuration;
pointer ctrl;
@@ -360,7 +365,7 @@ ProcXkbBell(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_BELL_DEVICE(dev,stuff->deviceSpec);
+ CHK_BELL_DEVICE(dev, stuff->deviceSpec, client, DixBellAccess);
CHK_ATOM_OR_NONE(stuff->name);
if ((stuff->forceSound)&&(stuff->eventOnly)) {
@@ -448,10 +453,10 @@ ProcXkbBell(ClientPtr client)
return BadValue;
}
if (stuff->window!=None) {
- pWin= (WindowPtr)LookupIDByType(stuff->window,RT_WINDOW);
- if (pWin==NULL) {
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
+ if (rc != Success) {
client->errorValue= stuff->window;
- return BadValue;
+ return rc;
}
}
else pWin= NULL;
@@ -499,7 +504,7 @@ ProcXkbGetState(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess);
xkb= &dev->key->xkbInfo->state;
bzero(&rep,sizeof(xkbGetStateReply));
@@ -544,7 +549,7 @@ ProcXkbLatchLockState(ClientPtr client)
if (!(client->xkbClientFlags & _XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev, stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);
CHK_MASK_MATCH(0x01, stuff->affectModLocks, stuff->modLocks);
CHK_MASK_MATCH(0x01, stuff->affectModLatches, stuff->modLatches);
@@ -612,7 +617,7 @@ ProcXkbGetControls(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
xkb = dev->key->xkbInfo->desc->ctrls;
rep.type = X_Reply;
@@ -689,7 +694,7 @@ ProcXkbSetControls(ClientPtr client)
if (!(client->xkbClientFlags & _XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev, stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);
CHK_MASK_LEGAL(0x01, stuff->changeCtrls, XkbAllControlsMask);
for (tmpd = inputInfo.keyboard; tmpd; tmpd = tmpd->next) {
@@ -1370,7 +1375,7 @@ ProcXkbGetMap(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
CHK_MASK_OVERLAP(0x01,stuff->full,stuff->partial);
CHK_MASK_LEGAL(0x02,stuff->full,XkbAllMapComponentsMask);
CHK_MASK_LEGAL(0x03,stuff->partial,XkbAllMapComponentsMask);
@@ -2299,7 +2304,7 @@ ProcXkbSetMap(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);
CHK_MASK_LEGAL(0x01,stuff->present,XkbAllMapComponentsMask);
XkbSetCauseXkbReq(&cause,X_kbSetMap,client);
@@ -2569,7 +2574,7 @@ ProcXkbGetCompatMap(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
xkb = dev->key->xkbInfo->desc;
compat= xkb->compat;
@@ -2613,7 +2618,7 @@ ProcXkbSetCompatMap(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);
data = (char *)&stuff[1];
xkbi = dev->key->xkbInfo;
@@ -2748,7 +2753,7 @@ ProcXkbGetIndicatorState(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess);
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,
XkbXI_IndicatorStateMask);
@@ -2859,7 +2864,7 @@ XkbIndicatorPtr leds;
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
xkb= dev->key->xkbInfo->desc;
leds= xkb->indicators;
@@ -2878,7 +2883,7 @@ int
ProcXkbSetIndicatorMap(ClientPtr client)
{
register int i,bit;
- int nIndicators,why;
+ int nIndicators;
DeviceIntPtr dev;
XkbSrvInfoPtr xkbi;
xkbIndicatorMapWireDesc *from;
@@ -2891,11 +2896,8 @@ ProcXkbSetIndicatorMap(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- dev = _XkbLookupKeyboard(stuff->deviceSpec,&why);
- if (!dev) {
- client->errorValue = _XkbErrCode2(why,stuff->deviceSpec);
- return XkbKeyboardErrorCode;
- }
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);
+
xkbi= dev->key->xkbInfo;
if (stuff->which==0)
@@ -2971,7 +2973,7 @@ ProcXkbGetNamedIndicator(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_LED_DEVICE(dev,stuff->deviceSpec);
+ CHK_LED_DEVICE(dev, stuff->deviceSpec, client, DixReadAccess);
CHK_ATOM_ONLY(stuff->indicator);
sli= XkbFindSrvLedInfo(dev,stuff->ledClass,stuff->ledID,0);
@@ -3057,7 +3059,7 @@ ProcXkbSetNamedIndicator(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_LED_DEVICE(dev,stuff->deviceSpec);
+ CHK_LED_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);
CHK_ATOM_ONLY(stuff->indicator);
CHK_MASK_LEGAL(0x10,stuff->whichGroups,XkbIM_UseAnyGroup);
CHK_MASK_LEGAL(0x11,stuff->whichMods,XkbIM_UseAnyMods);
@@ -3125,7 +3127,7 @@ ProcXkbSetNamedIndicator(ClientPtr client)
kbd= dev;
if ((sli->flags&XkbSLI_HasOwnState)==0)
- kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ kbd = inputInfo.keyboard;
XkbFlushLedEvents(dev,kbd,sli,&ed,&changes,&cause);
return client->noClientException;
}
@@ -3433,7 +3435,7 @@ ProcXkbGetNames(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask);
xkb = dev->key->xkbInfo->desc;
@@ -3543,7 +3545,7 @@ ProcXkbSetNames(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixUnknownAccess);
CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask);
xkb = dev->key->xkbInfo->desc;
@@ -4379,7 +4381,7 @@ ProcXkbGetGeometry(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
CHK_ATOM_OR_NONE(stuff->name);
geom= XkbLookupNamedGeometry(dev,stuff->name,&shouldFree);
@@ -4842,7 +4844,7 @@ ProcXkbSetGeometry(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);
CHK_ATOM_OR_NONE(stuff->name);
xkb= dev->key->xkbInfo->desc;
@@ -4897,6 +4899,7 @@ ProcXkbPerClientFlags(ClientPtr client)
DeviceIntPtr dev;
xkbPerClientFlagsReply rep;
XkbInterestPtr interest;
+ Mask access_mode = DixGetAttrAccess | DixSetAttrAccess;
REQUEST(xkbPerClientFlagsReq);
REQUEST_SIZE_MATCH(xkbPerClientFlagsReq);
@@ -4904,7 +4907,7 @@ ProcXkbPerClientFlags(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode);
CHK_MASK_LEGAL(0x01,stuff->change,XkbPCF_AllFlagsMask);
CHK_MASK_MATCH(0x02,stuff->change,stuff->value);
@@ -5040,7 +5043,7 @@ ProcXkbListComponents(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
status= Success;
str= (unsigned char *)&stuff[1];
@@ -5123,6 +5126,7 @@ ProcXkbGetKbdByName(ClientPtr client)
Bool geom_changed;
XkbSrvLedInfoPtr old_sli;
XkbSrvLedInfoPtr sli;
+ Mask access_mode = DixGetAttrAccess | DixSetAttrAccess;
REQUEST(xkbGetKbdByNameReq);
REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq);
@@ -5130,7 +5134,7 @@ ProcXkbGetKbdByName(ClientPtr client)
if (!(client->xkbClientFlags&_XkbClientInitialized))
return BadAccess;
- CHK_KBD_DEVICE(dev,stuff->deviceSpec);
+ CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode);
xkb = dev->key->xkbInfo->desc;
status= Success;
@@ -5664,7 +5668,7 @@ char * str;
wanted= stuff->wanted;
- CHK_ANY_DEVICE(dev,stuff->deviceSpec);
+ CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
CHK_MASK_LEGAL(0x01,wanted,XkbXI_AllDeviceFeaturesMask);
if ((!dev->button)||((stuff->nBtns<1)&&(!stuff->allBtns)))
@@ -5968,7 +5972,7 @@ DeviceIntPtr kbd;
kbd= dev;
if ((sli->flags&XkbSLI_HasOwnState)==0)
- kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ kbd = inputInfo.keyboard;
XkbFlushLedEvents(dev,kbd,sli,&ed,&changes,&cause);
ledWire= (xkbDeviceLedsWireDesc *)mapWire;
@@ -5993,7 +5997,7 @@ xkbExtensionDeviceNotify ed;
change= stuff->change;
- CHK_ANY_DEVICE(dev,stuff->deviceSpec);
+ CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);
CHK_MASK_LEGAL(0x01,change,XkbXI_AllFeaturesMask);
wire= (char *)&stuff[1];
@@ -6043,7 +6047,7 @@ xkbExtensionDeviceNotify ed;
ed.nBtns= stuff->nBtns;
if (dev->key) kbd= dev;
- else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ else kbd= inputInfo.keyboard;
acts= &dev->button->xkb_acts[stuff->firstBtn];
for (i=0;i<stuff->nBtns;i++,acts++) {
if (acts->type!=XkbSA_NoAction)
@@ -6069,10 +6073,15 @@ ProcXkbSetDebuggingFlags(ClientPtr client)
{
CARD32 newFlags,newCtrls,extraLength;
xkbSetDebuggingFlagsReply rep;
+int rc;
REQUEST(xkbSetDebuggingFlagsReq);
REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq);
+ rc = XaceHook(XACE_SERVER_ACCESS, client, DixDebugAccess);
+ if (rc != Success)
+ return rc;
+
newFlags= xkbDebugFlags&(~stuff->affectFlags);
newFlags|= (stuff->flags&stuff->affectFlags);
newCtrls= xkbDebugCtrls&(~stuff->affectCtrls);
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 43b82e162..d95fbcdde 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -694,7 +694,7 @@ ProcessPointerEvent( register xEvent * xE,
register DeviceIntPtr mouse,
int count)
{
-DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice();
+DeviceIntPtr dev = inputInfo.keyboard;
XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
unsigned changed = 0;
ProcessInputProc backupproc;
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 6edac292e..2aacc8ca6 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -42,8 +42,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <ctype.h>
#define EXTENSION_EVENT_BASE 64
-static unsigned int _xkbServerGeneration;
-int xkbDevicePrivateIndex = -1;
+DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKey;
void
xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
@@ -67,20 +66,12 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
{
xkbDeviceInfoPtr xkbPrivPtr;
- if (serverGeneration != _xkbServerGeneration) {
- if ((xkbDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1)
- return;
- _xkbServerGeneration = serverGeneration;
- }
- if (!AllocateDevicePrivate(device, xkbDevicePrivateIndex))
- return;
-
xkbPrivPtr = (xkbDeviceInfoPtr) xcalloc(1, sizeof(xkbDeviceInfoRec));
if (!xkbPrivPtr)
return;
xkbPrivPtr->unwrapProc = NULL;
- device->devPrivates[xkbDevicePrivateIndex].ptr = xkbPrivPtr;
+ dixSetPrivate(&device->devPrivates, xkbDevicePrivateKey, xkbPrivPtr);
WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc);
}
@@ -1045,8 +1036,9 @@ int button;
return 0;
if (filter->keycode==0) { /* initial press */
- dev= _XkbLookupButtonDevice(pAction->devbtn.device,NULL);
- if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice()))
+ _XkbLookupButtonDevice(&dev, pAction->devbtn.device, serverClient,
+ DixUnknownAccess, &button);
+ if (!dev || !dev->public.on || dev == inputInfo.pointer)
return 1;
button= pAction->devbtn.button;
@@ -1085,8 +1077,9 @@ int button;
int button;
filter->active= 0;
- dev= _XkbLookupButtonDevice(filter->upAction.devbtn.device,NULL);
- if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice()))
+ _XkbLookupButtonDevice(&dev, filter->upAction.devbtn.device,
+ serverClient, DixUnknownAccess, &button);
+ if (!dev || !dev->public.on || dev == inputInfo.pointer)
return 1;
button= filter->upAction.btn.button;
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index bf3e828f3..7643703e4 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -808,7 +808,7 @@ Bool
XkbFilterEvents(ClientPtr pClient,int nEvents,xEvent *xE)
{
int i, button_mask;
-DeviceIntPtr pXDev = (DeviceIntPtr)LookupKeyboardDevice();
+DeviceIntPtr pXDev = inputInfo.keyboard;
XkbSrvInfoPtr xkbi;
xkbi= pXDev->key->xkbInfo;
diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c
index d607d9066..2877af0c4 100644
--- a/xkb/xkbLEDs.c
+++ b/xkb/xkbLEDs.c
@@ -239,7 +239,7 @@ unsigned oldState;
if (dev->key && dev->key->xkbInfo)
kbd= dev;
- else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ else kbd= inputInfo.keyboard;
state= &kbd->key->xkbInfo->state;
ctrls= kbd->key->xkbInfo->desc->ctrls;
@@ -444,7 +444,7 @@ XkbIndicatorMapPtr map;
XkbDescPtr xkb;
if ((sli->flags&XkbSLI_HasOwnState)==0)
- dev= (DeviceIntPtr)LookupKeyboardDevice();
+ dev= inputInfo.keyboard;
sli->usesBase&= ~which;
sli->usesLatched&= ~which;
@@ -731,7 +731,7 @@ xkbExtensionDeviceNotify my_ed;
return;
if (dev->key && dev->key->xkbInfo)
kbd= dev;
- else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ else kbd= inputInfo.keyboard;
if (ed==NULL) {
ed= &my_ed;
@@ -808,7 +808,7 @@ xkbExtensionDeviceNotify my_ed;
return;
if (dev->key && dev->key->xkbInfo)
kbd= dev;
- else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ else kbd= inputInfo.keyboard;
if (ed==NULL) {
ed= &my_ed;
@@ -869,7 +869,7 @@ Bool kb_changed;
return;
if (dev->key && dev->key->xkbInfo)
kbd= dev;
- else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ else kbd= inputInfo.keyboard;
xkbi= kbd->key->xkbInfo;
if (changes==NULL) {
diff --git a/xkb/xkbPrOtherEv.c b/xkb/xkbPrOtherEv.c
index a2ea0909a..d65107cdc 100644
--- a/xkb/xkbPrOtherEv.c
+++ b/xkb/xkbPrOtherEv.c
@@ -71,7 +71,7 @@ Bool xkbCares,isBtn;
if ((!isBtn)||((dev->button)&&(dev->button->xkb_acts))) {
DeviceIntPtr kbd;
if (dev->key) kbd= dev;
- else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+ else kbd= inputInfo.keyboard;
XkbHandleActions(dev,kbd,xE,count);
return;
}
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index c7f9a2681..31c1a9fa9 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -49,92 +49,115 @@ int XkbDisableLockActions = 0;
/***====================================================================***/
-DeviceIntPtr
-_XkbLookupAnyDevice(int id,int *why_rtrn)
+int
+_XkbLookupAnyDevice(DeviceIntPtr *pDev, int id, ClientPtr client,
+ Mask access_mode, int *xkb_err)
{
-DeviceIntPtr dev = NULL;
+ int rc = XkbKeyboardErrorCode;
- dev= (DeviceIntPtr)LookupKeyboardDevice();
- if ((id==XkbUseCoreKbd)||(dev->id==id))
- return dev;
-
- dev= (DeviceIntPtr)LookupPointerDevice();
- if ((id==XkbUseCorePtr)||(dev->id==id))
- return dev;
-
- if (id&(~0xff))
- dev = NULL;
-
- dev= (DeviceIntPtr)LookupDevice(id);
- if (dev!=NULL)
- return dev;
- if ((!dev)&&(why_rtrn))
- *why_rtrn= XkbErr_BadDevice;
- return dev;
+ if (id == XkbUseCoreKbd) {
+ if (inputInfo.keyboard)
+ id = inputInfo.keyboard->id;
+ else
+ goto out;
+ }
+ if (id == XkbUseCorePtr) {
+ if (inputInfo.pointer)
+ id = inputInfo.pointer->id;
+ else
+ goto out;
+ }
+ rc = dixLookupDevice(pDev, id, client, access_mode);
+out:
+ if (rc != Success)
+ *xkb_err = XkbErr_BadDevice;
+ return rc;
}
-DeviceIntPtr
-_XkbLookupKeyboard(int id,int *why_rtrn)
+int
+_XkbLookupKeyboard(DeviceIntPtr *pDev, int id, ClientPtr client,
+ Mask access_mode, int *xkb_err)
{
-DeviceIntPtr dev = NULL;
+ DeviceIntPtr dev;
+ int rc;
if (id == XkbDfltXIId)
id = XkbUseCoreKbd;
- if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
- return NULL;
- else if ((!dev->key)||(!dev->key->xkbInfo)) {
- if (why_rtrn)
- *why_rtrn= XkbErr_BadClass;
- return NULL;
+
+ rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err);
+ if (rc != Success)
+ return rc;
+
+ dev = *pDev;
+ if (!dev->key || !dev->key->xkbInfo) {
+ *pDev = NULL;
+ *xkb_err= XkbErr_BadClass;
+ return XkbKeyboardErrorCode;
}
- return dev;
+ return Success;
}
-DeviceIntPtr
-_XkbLookupBellDevice(int id,int *why_rtrn)
+int
+_XkbLookupBellDevice(DeviceIntPtr *pDev, int id, ClientPtr client,
+ Mask access_mode, int *xkb_err)
{
-DeviceIntPtr dev = NULL;
-
- if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
- return NULL;
- else if ((!dev->kbdfeed)&&(!dev->bell)) {
- if (why_rtrn)
- *why_rtrn= XkbErr_BadClass;
- return NULL;
+ DeviceIntPtr dev;
+ int rc;
+
+ rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err);
+ if (rc != Success)
+ return rc;
+
+ dev = *pDev;
+ if (!dev->kbdfeed && !dev->bell) {
+ *pDev = NULL;
+ *xkb_err= XkbErr_BadClass;
+ return XkbKeyboardErrorCode;
}
- return dev;
+ return Success;
}
-DeviceIntPtr
-_XkbLookupLedDevice(int id,int *why_rtrn)
+int
+_XkbLookupLedDevice(DeviceIntPtr *pDev, int id, ClientPtr client,
+ Mask access_mode, int *xkb_err)
{
-DeviceIntPtr dev = NULL;
+ DeviceIntPtr dev;
+ int rc;
if (id == XkbDfltXIId)
id = XkbUseCorePtr;
- if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
- return NULL;
- else if ((!dev->kbdfeed)&&(!dev->leds)) {
- if (why_rtrn)
- *why_rtrn= XkbErr_BadClass;
- return NULL;
+
+ rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err);
+ if (rc != Success)
+ return rc;
+
+ dev = *pDev;
+ if (!dev->kbdfeed && !dev->leds) {
+ *pDev = NULL;
+ *xkb_err= XkbErr_BadClass;
+ return XkbKeyboardErrorCode;
}
- return dev;
+ return Success;
}
-DeviceIntPtr
-_XkbLookupButtonDevice(int id,int *why_rtrn)
+int
+_XkbLookupButtonDevice(DeviceIntPtr *pDev, int id, ClientPtr client,
+ Mask access_mode, int *xkb_err)
{
-DeviceIntPtr dev = NULL;
-
- if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
- return NULL;
- else if (!dev->button) {
- if (why_rtrn)
- *why_rtrn= XkbErr_BadClass;
- return NULL;
+ DeviceIntPtr dev;
+ int rc;
+
+ rc = _XkbLookupAnyDevice(pDev, id, client, access_mode, xkb_err);
+ if (rc != Success)
+ return rc;
+
+ dev = *pDev;
+ if (!dev->button) {
+ *pDev = NULL;
+ *xkb_err= XkbErr_BadClass;
+ return XkbKeyboardErrorCode;
}
- return dev;
+ return Success;
}
void