From e98eebf9c9745228b76319d615ca6ee4a62a0f6f Mon Sep 17 00:00:00 2001 From: graemeg Date: Fri, 7 Mar 2008 12:54:40 +0000 Subject: * TfpgForm now has a FullScreen property. Currently only implemented in X11. * TfpgForm also has a new method SetFullscreen(boolean) which allows you to switch fullscreen mode at any time. --- src/corelib/gfxbase.pas | 12 +++++++++++- src/corelib/x11/gfx_x11.pas | 10 ++++++++++ src/gui/gui_form.pas | 8 ++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index ffba04bb..276f5a38 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -24,7 +24,7 @@ type TWindowType = (wtChild, wtWindow, wtModalForm, wtPopup); - TWindowAttribute = (waSizeable, waAutoPos, waScreenCenterPos, waStayOnTop); + TWindowAttribute = (waSizeable, waAutoPos, waScreenCenterPos, waStayOnTop, waFullScreen); TWindowAttributes = set of TWindowAttribute; TMouseCursor = (mcDefault, mcArrow, mcCross, mcIBeam, mcSizeEW, mcSizeNS, @@ -364,6 +364,7 @@ type function WindowToScreen(ASource: TfpgWindowBase; const AScreenPos: TPoint): TPoint; procedure CaptureMouse; virtual; abstract; procedure ReleaseMouse; virtual; abstract; + procedure SetFullscreen(AValue: Boolean); virtual; property HasHandle: boolean read HandleIsValid; property WindowType: TWindowType read FWindowType write FWindowType; property WindowAttributes: TWindowAttributes read FWindowAttributes write FWindowAttributes; @@ -883,6 +884,15 @@ begin Result := DoWindowToScreen(ASource, AScreenPos); end; +procedure TfpgWindowBase.SetFullscreen(AValue: Boolean); +begin + if AValue then + Include(FWindowAttributes, waFullScreen) + else + Exclude(FWindowAttributes, waFullScreen); + // now decendants must override this and implement the actualy fullscreen part +end; + { TfpgCanvasBase } procedure TfpgCanvasBase.SetInterpolation(const AValue: TfpgCustomInterpolation); diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index 94c86a88..65533570 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -147,6 +147,7 @@ type constructor Create(AOwner: TComponent); override; procedure CaptureMouse; override; procedure ReleaseMouse; override; + procedure SetFullscreen(AValue: Boolean); override; end; @@ -1346,6 +1347,9 @@ begin AllocateWindowHandle; XMapWindow(xapplication.Display, FWinHandle); Include(FWinFlags, xwsfMapped); + // Fullscreen can only be set visible (mapped) windows. + if waFullScreen in FWindowAttributes then + fpgApplication.netlayer.WindowSetFullscreen(FWinHandle, True); end else begin @@ -1473,6 +1477,12 @@ begin XUngrabPointer(xapplication.display, CurrentTime); end; +procedure TfpgWindowImpl.SetFullscreen(AValue: Boolean); +begin + inherited SetFullscreen(AValue); + fpgApplication.netlayer.WindowSetFullscreen(FWinHandle, AValue); +end; + { TfpgFontResourceImpl } constructor TfpgFontResourceImpl.Create(const afontdesc: string); diff --git a/src/gui/gui_form.pas b/src/gui/gui_form.pas index 173ea714..b38cee83 100644 --- a/src/gui/gui_form.pas +++ b/src/gui/gui_form.pas @@ -34,6 +34,7 @@ type TfpgForm = class(TfpgWidget) private + FFullScreen: boolean; FOnActivate: TNotifyEvent; FOnClose: TNotifyEvent; FOnCreate: TNotifyEvent; @@ -69,6 +70,7 @@ type procedure Close; property Sizeable: boolean read FSizeable write FSizeable; property ModalResult: integer read FModalResult write FModalResult; + property FullScreen: boolean read FFullScreen write FFullScreen default False; published {$Note Refactor this to a TfpgCustomForm and only surface it here } property BackgroundColor; @@ -182,6 +184,11 @@ begin Include(FWindowAttributes, waSizeable) else Exclude(FWindowAttributes, waSizeable); + + if FFullScreen then + Include(FWindowAttributes, waFullScreen) + else + Exclude(FWindowAttributes, waFullScreen); end; procedure TfpgForm.SetWindowParameters; @@ -202,6 +209,7 @@ begin FMinWidth := 32; FMinHeight := 32; FModalResult := 0; + FFullScreen := False; AfterCreate; end; -- cgit v1.2.3-70-g09d2