mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 22:20:19 +02:00
added gtk x functions to toggle a form fullscreen, grab mouse and capture keyboard thx to Andrew Haines
git-svn-id: trunk@9727 -
This commit is contained in:
parent
a991d209ed
commit
dff0858e3d
@ -1,2 +1,2 @@
|
|||||||
// Created by Svn2RevisionInc
|
// Created by Svn2RevisionInc
|
||||||
const RevisionStr = '9724M';
|
const RevisionStr = '9724:9725M';
|
||||||
|
@ -369,6 +369,19 @@ begin
|
|||||||
result := gdk_window_get_colormap(Drawable);
|
result := gdk_window_get_colormap(Drawable);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function FormToX11Window(const AForm: TCustomForm): X.TWindow;
|
||||||
|
var
|
||||||
|
GdkWindow: PGdkWindowPrivate;
|
||||||
|
Widget: PGtkWidget;
|
||||||
|
begin
|
||||||
|
Result:=0;
|
||||||
|
if (AForm=nil) or (not AForm.HandleAllocated) then exit;
|
||||||
|
Widget:=PGtkWidget(AForm.Handle);
|
||||||
|
GdkWindow := PGdkWindowPrivate(Widget^.window);
|
||||||
|
if GdkWindow=nil then exit;
|
||||||
|
Result := GdkWindow^.xwindow;
|
||||||
|
end;
|
||||||
|
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
|
|
||||||
{$Ifdef GTK2}
|
{$Ifdef GTK2}
|
||||||
@ -1000,6 +1013,90 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure SetWindowFullScreen(AForm: TCustomForm; const AValue: Boolean);
|
||||||
|
{$IFDEF HasGtkX}
|
||||||
|
var
|
||||||
|
XDisplay: PDisplay;
|
||||||
|
XScreen: PScreen;
|
||||||
|
XRootWindow,
|
||||||
|
XWindow: TWindow;
|
||||||
|
XEvent: TXClientMessageEvent;
|
||||||
|
_NET_WM_STATE: Integer;
|
||||||
|
//_NET_WM_STATE_MODAL: Integer;
|
||||||
|
//_NET_WM_STATE_ABOVE: Integer;
|
||||||
|
//_NET_WM_STATE_FULLSCREEN: Integer;
|
||||||
|
_NET_WM_STATE_ATOMS: array [0..2] of Integer;
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
XDisplay := gdk_display;
|
||||||
|
XScreen := XDefaultScreenOfDisplay(xdisplay);
|
||||||
|
XRootWindow := XRootWindowOfScreen(xscreen);
|
||||||
|
XWindow := FormToX11Window(AForm);
|
||||||
|
|
||||||
|
_NET_WM_STATE := XInternAtom(xdisplay, '_NET_WM_STATE', false);
|
||||||
|
//_NET_WM_STATE_MODAL := XInternAtom(xdisplay, '_NET_WM_STATE_MODAL', false);
|
||||||
|
//_NET_WM_STATE_ABOVE := XInternAtom(xdisplay, '_NET_WM_STATE_ABOVE', false);
|
||||||
|
//_NET_WM_STATE_FULLSCREEN := XInternAtom(xdisplay, '_NET_WM_STATE_FULLSCREEN', false);
|
||||||
|
_NET_WM_STATE_ATOMS[0] := XInternAtom(xdisplay, '_NET_WM_STATE_MODAL', false);
|
||||||
|
_NET_WM_STATE_ATOMS[1] := XInternAtom(xdisplay, '_NET_WM_STATE_ABOVE', false);
|
||||||
|
_NET_WM_STATE_ATOMS[2] := XInternAtom(xdisplay, '_NET_WM_STATE_FULLSCREEN', false);
|
||||||
|
|
||||||
|
for I := 0 to 2 do begin
|
||||||
|
XEvent._type := ClientMessage;
|
||||||
|
XEvent.window := XWindow;
|
||||||
|
XEvent.message_type := _NET_WM_STATE;
|
||||||
|
XEvent.format := 32;
|
||||||
|
XEvent.data.l[0] := Ord(AValue);// 0=Remove 1=Add 2=Toggle
|
||||||
|
XEvent.data.l[1] := _NET_WM_STATE_ATOMS[I];
|
||||||
|
|
||||||
|
XSendEvent(XDisplay, XRootWindow, False, SubstructureNotifyMask, @XEvent);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ELSE}
|
||||||
|
begin
|
||||||
|
RaiseGDBException('not implemented');
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
procedure GrabKeyBoardToForm(AForm: TCustomForm);
|
||||||
|
begin
|
||||||
|
{$IFDEF HasGtkX}
|
||||||
|
XGrabKeyboard(gdk_display, FormToX11Window(AForm), true, GrabModeASync,
|
||||||
|
GrabModeASync, CurrentTime);
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ReleaseKeyBoardFromForm(AForm: TCustomForm);
|
||||||
|
begin
|
||||||
|
{$IFDEF HasGtkX}
|
||||||
|
XUngrabKeyboard(gdk_display, CurrentTime);
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure GrabMouseToForm(AForm: TCustomForm);
|
||||||
|
{$IFDEF HasGtkX}
|
||||||
|
var
|
||||||
|
eventMask: LongInt;
|
||||||
|
begin
|
||||||
|
eventMask := ButtonPressMask or ButtonReleaseMask
|
||||||
|
or PointerMotionMask or PointerMotionHintMask;
|
||||||
|
|
||||||
|
XGrabPointer(gdk_display, FormToX11Window(AForm), true,
|
||||||
|
eventMask, GrabModeASync, GrabModeAsync, FormToX11Window(AForm),
|
||||||
|
None, CurrentTime);
|
||||||
|
end;
|
||||||
|
{$ELSE}
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
procedure ReleaseMouseFromForm(AForm: TCustomForm);
|
||||||
|
begin
|
||||||
|
{$IFDEF HasGtkX}
|
||||||
|
XUngrabPointer(gdk_display, CurrentTime);
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
procedure SetComboBoxText(ComboWidget: PGtkCombo; const NewText: string);
|
procedure SetComboBoxText(ComboWidget: PGtkCombo; const NewText: string);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ unit GTKProc;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
{$IFDEF win32}
|
{$IFDEF win32}
|
||||||
{.$DEFINE NoGdkPixbufLib}
|
{off $DEFINE NoGdkPixbufLib}
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
{off $DEFINE NoGdkPixbufLib}
|
{off $DEFINE NoGdkPixbufLib}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -29,16 +29,25 @@ interface
|
|||||||
|
|
||||||
{off $DEFINE VerboseAccelerator}
|
{off $DEFINE VerboseAccelerator}
|
||||||
|
|
||||||
|
{$IFDEF Unix}
|
||||||
|
{$DEFINE HasX}
|
||||||
|
{$IFDEF Gtk1}
|
||||||
|
{$DEFINE HasGtkX}
|
||||||
|
{$ENDIF}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFDEF win32}
|
{$IFDEF win32}
|
||||||
// use windows unit first,
|
// use windows unit first,
|
||||||
// if not, Rect and Point are taken from the windows unit instead of classes.
|
// if not, Rect and Point are taken from the windows unit instead of classes.
|
||||||
Windows, // needed for keyboard handling
|
Windows, // needed for keyboard handling
|
||||||
{$endif}
|
{$endif}
|
||||||
|
{$IFDEF Unix}
|
||||||
|
baseunix, unix,
|
||||||
|
{$ENDIF}
|
||||||
SysUtils, Classes, FPCAdds,
|
SysUtils, Classes, FPCAdds,
|
||||||
{$IFDEF UNIX}
|
{$IFDEF HasX}
|
||||||
baseunix, unix, XAtom,
|
XAtom, X, XLib, XUtil, //Font retrieval and Keyboard handling
|
||||||
X, XLib, XUtil, //Font retrieval and Keyboard handling
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
InterfaceBase,
|
InterfaceBase,
|
||||||
{$IFDEF gtk2}
|
{$IFDEF gtk2}
|
||||||
@ -125,7 +134,7 @@ const
|
|||||||
|
|
||||||
// missing gtk2 functions/vars
|
// missing gtk2 functions/vars
|
||||||
{$IFDEF GTK2}
|
{$IFDEF GTK2}
|
||||||
{$IFDEF UNIX}
|
{$IFDEF Unix}
|
||||||
var
|
var
|
||||||
gdk_display: PDisplay; external gdkdll name 'gdk_display';
|
gdk_display: PDisplay; external gdkdll name 'gdk_display';
|
||||||
|
|
||||||
@ -420,6 +429,11 @@ procedure HideCaretOfWidgetGroup(ChildWidget: PGtkWidget;
|
|||||||
procedure SetFormShowInTaskbar(AForm: TCustomForm;
|
procedure SetFormShowInTaskbar(AForm: TCustomForm;
|
||||||
const AValue: TShowInTaskbar);
|
const AValue: TShowInTaskbar);
|
||||||
procedure SetGtkWindowShowInTaskbar(AGtkWindow: PGtkWindow; Value: boolean);
|
procedure SetGtkWindowShowInTaskbar(AGtkWindow: PGtkWindow; Value: boolean);
|
||||||
|
procedure SetWindowFullScreen(AForm: TCustomForm; const AValue: Boolean);
|
||||||
|
procedure GrabKeyBoardToForm(AForm: TCustomForm);
|
||||||
|
procedure ReleaseKeyBoardFromForm(AForm: TCustomForm);
|
||||||
|
procedure GrabMouseToForm(AForm: TCustomForm);
|
||||||
|
procedure ReleaseMouseFromForm(AForm: TCustomForm);
|
||||||
|
|
||||||
// combobox
|
// combobox
|
||||||
procedure SetComboBoxText(ComboWidget: PGtkCombo; NewText: PChar);
|
procedure SetComboBoxText(ComboWidget: PGtkCombo; NewText: PChar);
|
||||||
@ -541,6 +555,10 @@ procedure ReleaseMouseCapture;
|
|||||||
procedure ReleaseCaptureWidget(Widget : PGtkWidget);
|
procedure ReleaseCaptureWidget(Widget : PGtkWidget);
|
||||||
procedure UpdateMouseCaptureControl;
|
procedure UpdateMouseCaptureControl;
|
||||||
|
|
||||||
|
// mouse cursor
|
||||||
|
function GetGDKMouseCursor(Cursor: TCursor): PGdkCursor;
|
||||||
|
Procedure FreeGDKCursors;
|
||||||
|
|
||||||
// designing
|
// designing
|
||||||
type
|
type
|
||||||
TConnectSignalFlag = (
|
TConnectSignalFlag = (
|
||||||
@ -679,6 +697,7 @@ procedure Accelerate(Component: TComponent; const Widget: PGtkWidget;
|
|||||||
procedure ShareWindowAccelGroups(AWindow: PGtkWidget);
|
procedure ShareWindowAccelGroups(AWindow: PGtkWidget);
|
||||||
procedure UnshareWindowAccelGroups(AWindow: PGtkWidget);
|
procedure UnshareWindowAccelGroups(AWindow: PGtkWidget);
|
||||||
|
|
||||||
|
// pixbuf
|
||||||
procedure LoadPixbufFromLazResource(const ResourceName: string;
|
procedure LoadPixbufFromLazResource(const ResourceName: string;
|
||||||
var Pixbuf: PGdkPixbuf);
|
var Pixbuf: PGdkPixbuf);
|
||||||
procedure LoadXPMFromLazResource(const ResourceName: string;
|
procedure LoadXPMFromLazResource(const ResourceName: string;
|
||||||
@ -786,10 +805,6 @@ function XGetWorkarea(var ax,ay,awidth,aheight:gint): gint;
|
|||||||
Function GetWindowDecorations(AForm: TCustomForm): Longint;
|
Function GetWindowDecorations(AForm: TCustomForm): Longint;
|
||||||
Function GetWindowFunction(AForm: TCustomForm): Longint;
|
Function GetWindowFunction(AForm: TCustomForm): Longint;
|
||||||
|
|
||||||
// mouse cursor
|
|
||||||
function GetGDKMouseCursor(Cursor: TCursor): PGdkCursor;
|
|
||||||
Procedure FreeGDKCursors;
|
|
||||||
|
|
||||||
// functions for easier GTK2<->GTK1 Compatibility/Consistency ---->
|
// functions for easier GTK2<->GTK1 Compatibility/Consistency ---->
|
||||||
function gtk_widget_get_xthickness(Style: PGTKStyle): gint; overload;
|
function gtk_widget_get_xthickness(Style: PGTKStyle): gint; overload;
|
||||||
function gtk_widget_get_ythickness(Style: PGTKStyle): gint; overload;
|
function gtk_widget_get_ythickness(Style: PGTKStyle): gint; overload;
|
||||||
@ -909,11 +924,17 @@ var
|
|||||||
LineLength: Longint; lbearing, rbearing, width, ascent, descent: Pgint);
|
LineLength: Longint; lbearing, rbearing, width, ascent, descent: Pgint);
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
|
|
||||||
|
{$IFDEF HasGtkX}
|
||||||
|
// X functions
|
||||||
|
function FormToX11Window(const AForm: TCustomForm): X.TWindow;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
uses {$IFDEF StaticXinerama} Xinerama, {$ENDIF}
|
uses
|
||||||
{$IFDEF USE_UTF8BIDI_LCL} utf8bidi, {$ENDIF} dynlibs;
|
{$IFDEF StaticXinerama} Xinerama, {$ENDIF}
|
||||||
|
dynlibs;
|
||||||
|
|
||||||
const
|
const
|
||||||
VKEY_FLAG_SHIFT = $01;
|
VKEY_FLAG_SHIFT = $01;
|
||||||
|
Loading…
Reference in New Issue
Block a user