unit X11_Screens; {$MODE OBJFPC} {$M+} interface uses X11_Objects, X11, type_fixes, xlib; type TScreen = class(system.TObject) // (X11_Objects.TObject, {IScreen, X11_Objects.IObject, IInterface) private fRootWindow : IWindow; fDefaultVisual : IVisual; fScreen : PScreen; fDisplay : PDisplay; protected function GetRootWindow : IWindow; function GetDefaultDepth : TInteger; function GetDefaultVisual : IVisual; function GetWidthMM : TInteger; function GetHeightMM : TInteger; function GetWidthPixels : TInteger; function GetHeightPixels : TInteger; published property RootWindow : IWindow read GetRootWindow; property DefaultDepth : TInteger read GetDefaultDepth; property DefaultVisual : IVisual read GetDefaultVisual; constructor Reuse(aDisplay : PDisplay; aScreen : PScreen; aBOwnsScreen : Boolean = False); // TODO: (can these change in the lifetime of a X server?) // depths. // default gc. // display cells. // display string. // #define BlackPixelOfScreen(s) // #define WhitePixelOfScreen(s) // #define DefaultColormapOfScreen(s)((s)->cmap) // #define DefaultDepthOfScreen(s) ((s)->root_depth) // #define DefaultGCOfScreen(s) ((s)->default_gc) //#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries) //#define MinCmapsOfScreen(s) ((s)->min_maps) //#define MaxCmapsOfScreen(s) ((s)->max_maps) //#define DoesSaveUnders(s) ((s)->save_unders) //#define DoesBackingStore(s) ((s)->backing_store) //#define EventMaskOfScreen(s) ((s)->root_input_mask) property WidthMM : TInteger read GetWidthMM; property HeightMM : TInteger read GetHeightMM; property WidthPixels : TInteger read GetWidthPixels; property HeightPixels : TInteger read GetHeightPixels; public property Display : PDisplay read fDisplay; end; TScreenArray = array of TScreen; implementation uses X11_Windows, X11_Visuals; function TScreen.GetRootWindow : IWindow; begin if not Assigned(fRootWindow) then fRootWindow := TWindow.Reuse(Display, RootWindowOfScreen(fScreen), False); Result := fRootWindow; end; function TScreen.GetDefaultDepth : TInteger; begin Result := DefaultDepthOfScreen(fScreen); end; function TScreen.GetDefaultVisual : IVisual; begin if not Assigned(fDefaultVisual) then fDefaultVisual := X11_Visuals.TVisual.Reuse(Display, DefaultVisualOfScreen(fScreen), True); Result := fDefaultVisual; end; function TScreen.GetWidthMM : TInteger; begin Result := WidthMMOfScreen(fScreen); end; function TScreen.GetHeightMM : TInteger; begin Result := HeightMMOfScreen(fScreen); end; function TScreen.GetWidthPixels : TInteger; begin Result := WidthOfScreen(fScreen); end; function TScreen.GetHeightPixels : TInteger; begin Result := HeightOfScreen(fScreen); end; constructor TScreen.Reuse(aDisplay : PDisplay; aScreen : PScreen; aBOwnsScreen : Boolean); begin fDisplay := aDisplay; fScreen := aScreen; end; end.