unit X11_SHM_Extension; {$MODE OBJFPC} {$M+} interface uses X11, type_fixes, xlib, X11_Objects, X, sysutils; type EUnsupportedPixmapFormat = class(Exception) end; TSHMExtension = class(TInterfacedObject, ISHMExtension, IInterface) private fMajorVersion : Integer; fMinorVersion : Integer; fBSharedMemoryPixmaps : Longint; fPixmapFormat : TPixmapFormat; protected function GetMajorVersion : Integer; function GetMinorVersion : Integer; function GetBSharedMemoryPixmaps : Boolean; public function GetPixmapFormat : TPixmapFormat; published property MajorVersion : Integer read GetMajorVersion; property MinorVersion : Integer read GetMinorVersion; property BSharedMemoryPixmaps : Boolean read GetBSharedMemoryPixmaps; constructor Open(aDisplay : PDisplay); public property PixmapFormat : TPixmapFormat read GetPixmapFormat; // depth, bits_per_pixel, scanline_pad. end; implementation uses xshm; function TSHMExtension.GetMajorVersion : Integer; begin Result := fMajorVersion; end; function TSHMExtension.GetMinorVersion : Integer; begin Result := fMinorVersion; end; function TSHMExtension.GetBSharedMemoryPixmaps : Boolean; begin Result := Boolean(fBSharedMemoryPixmaps); end; function TSHMExtension.GetPixmapFormat : TPixmapFormat; begin Result := fPixmapFormat; end; constructor TSHMExtension.Open(aDisplay : PDisplay); var vPixmapFormat : TStatus; begin if (XShmQueryExtension(aDisplay) = LongInt(False)) or (XShmQueryVersion(aDisplay, @fMajorVersion, @fMinorVersion, @fBSharedMemoryPixmaps) = LongInt(False)) then raise EFormatError.Create('X11 SHM Extension not available.'); vPixmapFormat := CheckError(XShmPixmapFormat(aDisplay)); if vPixmapFormat <> ZPixmap then begin raise EUnsupportedPixmapFormat.Create(IntToStr(vPixmapFormat)); end; // FIXME -> fPixmapFormat. end; end.