diff --git a/ide/revision.inc b/ide/revision.inc index e0d3baf0b4..96568f847c 100644 --- a/ide/revision.inc +++ b/ide/revision.inc @@ -1,2 +1,2 @@ // Created by Svn2RevisionInc -const RevisionStr = '9724M'; +const RevisionStr = '9724:9725M'; diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index 64815f987e..a4c182ab3e 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -369,6 +369,19 @@ begin result := gdk_window_get_colormap(Drawable); 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} {$Ifdef GTK2} @@ -1000,6 +1013,90 @@ begin {$ENDIF} 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); diff --git a/lcl/interfaces/gtk/gtkproc.pp b/lcl/interfaces/gtk/gtkproc.pp index 8dc54cabc0..e1035b648c 100644 --- a/lcl/interfaces/gtk/gtkproc.pp +++ b/lcl/interfaces/gtk/gtkproc.pp @@ -19,7 +19,7 @@ unit GTKProc; interface {$IFDEF win32} -{.$DEFINE NoGdkPixbufLib} +{off $DEFINE NoGdkPixbufLib} {$ELSE} {off $DEFINE NoGdkPixbufLib} {$ENDIF} @@ -29,16 +29,25 @@ interface {off $DEFINE VerboseAccelerator} +{$IFDEF Unix} + {$DEFINE HasX} + {$IFDEF Gtk1} + {$DEFINE HasGtkX} + {$ENDIF} +{$ENDIF} + uses {$IFDEF win32} // use windows unit first, // if not, Rect and Point are taken from the windows unit instead of classes. Windows, // needed for keyboard handling {$endif} + {$IFDEF Unix} + baseunix, unix, + {$ENDIF} SysUtils, Classes, FPCAdds, - {$IFDEF UNIX} - baseunix, unix, XAtom, - X, XLib, XUtil, //Font retrieval and Keyboard handling + {$IFDEF HasX} + XAtom, X, XLib, XUtil, //Font retrieval and Keyboard handling {$ENDIF} InterfaceBase, {$IFDEF gtk2} @@ -125,7 +134,7 @@ const // missing gtk2 functions/vars {$IFDEF GTK2} -{$IFDEF UNIX} +{$IFDEF Unix} var gdk_display: PDisplay; external gdkdll name 'gdk_display'; @@ -420,6 +429,11 @@ procedure HideCaretOfWidgetGroup(ChildWidget: PGtkWidget; procedure SetFormShowInTaskbar(AForm: TCustomForm; const AValue: TShowInTaskbar); 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 procedure SetComboBoxText(ComboWidget: PGtkCombo; NewText: PChar); @@ -541,6 +555,10 @@ procedure ReleaseMouseCapture; procedure ReleaseCaptureWidget(Widget : PGtkWidget); procedure UpdateMouseCaptureControl; +// mouse cursor +function GetGDKMouseCursor(Cursor: TCursor): PGdkCursor; +Procedure FreeGDKCursors; + // designing type TConnectSignalFlag = ( @@ -679,6 +697,7 @@ procedure Accelerate(Component: TComponent; const Widget: PGtkWidget; procedure ShareWindowAccelGroups(AWindow: PGtkWidget); procedure UnshareWindowAccelGroups(AWindow: PGtkWidget); +// pixbuf procedure LoadPixbufFromLazResource(const ResourceName: string; var Pixbuf: PGdkPixbuf); procedure LoadXPMFromLazResource(const ResourceName: string; @@ -786,10 +805,6 @@ function XGetWorkarea(var ax,ay,awidth,aheight:gint): gint; Function GetWindowDecorations(AForm: TCustomForm): Longint; Function GetWindowFunction(AForm: TCustomForm): Longint; -// mouse cursor -function GetGDKMouseCursor(Cursor: TCursor): PGdkCursor; -Procedure FreeGDKCursors; - // functions for easier GTK2<->GTK1 Compatibility/Consistency ----> function gtk_widget_get_xthickness(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); {$EndIf} +{$IFDEF HasGtkX} +// X functions +function FormToX11Window(const AForm: TCustomForm): X.TWindow; +{$ENDIF} + implementation -uses {$IFDEF StaticXinerama} Xinerama, {$ENDIF} - {$IFDEF USE_UTF8BIDI_LCL} utf8bidi, {$ENDIF} dynlibs; +uses + {$IFDEF StaticXinerama} Xinerama, {$ENDIF} + dynlibs; const VKEY_FLAG_SHIFT = $01;