unit X11_Shared_Memory; interface uses X11_Objects, X11, SYSV, xshm, type_fixes, xlib; type TSHMSegment = class(X11_Objects.TObject, ISHMSegment, X11_Objects.IObject, IInterface) private fBReadOnly : Boolean; fSharedMemory : SYSV.ISharedMemory; // kernel side. fSegmentInfo : TXShmSegmentInfo; // { ShmSeg shmseg; /\(* resource id */ int shmid; /\(* kernel id */ char *shmaddr; /\(* address in client */ Bool readOnly; /\(* how the server should attach it */ } protected procedure DeleteUnderlyingObject; override; function GetSharedMemory : ISharedMemory; function GetBReadOnly : TBoolean; published constructor Attach(aDisplay : PDisplay; const aSharedMemory : ISharedMemory; aBReadOnly : TBoolean = False); property SharedMemory : ISharedMemory read GetSharedMemory; property BReadOnly : TBoolean read GetBReadOnly; end; implementation { XShmQueryExtension checks to see if the shared memory extensions are available for the specified display. XShmQueryVersion returns the version numbers of the extension implementation. Shared memory pixmaps are supported if the pixmaps argument returns true. } procedure TSHMSegment.DeleteUnderlyingObject; begin if fSegmentInfo.shmseg <> 0 then begin // FIXME is that correct? CheckError(XShmDetach(Display, @fSegmentInfo)); // .shmseg)); fSegmentInfo.shmseg := 0; end; end; function TSHMSegment.GetSharedMemory : ISharedMemory; begin Result := fSharedMemory; end; function TSHMSegment.GetBReadOnly : TBoolean; begin Result := fBReadOnly; end; constructor TSHMSegment.Attach(aDisplay : PDisplay; const aSharedMemory : ISharedMemory; aBReadOnly : TBoolean); begin fSharedMemory := aSharedMemory; fSegmentInfo.shmid := aSharedMemory.ID; fSegmentInfo.shmaddr := aSharedMemory.Address; if aBReadOnly then fSegmentInfo.readOnly := LongInt(True) else fSegmentInfo.readOnly := LongInt(False); CheckError(XShmAttach(aDisplay, @fSegmentInfo)); inherited Reuse(aDisplay, fSegmentInfo.shmseg, True); end; end.