mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-04 23:58:14 +02:00
Form.WindowState now is kept up to date from Andrew Haines
git-svn-id: trunk@8561 -
This commit is contained in:
parent
f3454c0129
commit
acebd87695
@ -1151,7 +1151,14 @@ procedure TGtkWidgetSet.SendCachedGtkMessages;
|
||||
begin
|
||||
Result := 0;
|
||||
Msg := LM_SIZE;
|
||||
{$IFDEF GTK1}
|
||||
if GDK_WINDOW_GET_MAXIMIZED(PGdkWindowPrivate(MainWidget^.window)) then
|
||||
SizeType := SIZEFULLSCREEN or Size_SourceIsInterface
|
||||
else
|
||||
SizeType := SIZENORMAL or Size_SourceIsInterface;
|
||||
{$ELSE}
|
||||
SizeType := Size_SourceIsInterface;
|
||||
{$ENDIF}
|
||||
Width := SmallInt(GtkWidth);
|
||||
Height := SmallInt(GtkHeight);
|
||||
end;
|
||||
|
@ -95,6 +95,7 @@ const
|
||||
procedure GDK_WINDOW_ACTIVATE(Window: PGdkWindowPrivate);
|
||||
procedure GDK_WINDOW_MAXIMIZE(Window: PGdkWindowPrivate);
|
||||
procedure GDK_WINDOW_MINIMIZE(Window: PGdkWindowPrivate);
|
||||
function GDK_WINDOW_GET_MAXIMIZED(Window: PGdkWindowPrivate): gboolean;
|
||||
procedure GDK_WINDOW_SHOW_IN_TASKBAR(Window: PGdkWindowPrivate; Show: Boolean);
|
||||
{$ENDIF}
|
||||
|
||||
@ -1184,6 +1185,8 @@ begin
|
||||
XSendEvent(XDisplay, aXRootWindow, False, SubstructureNotifyMask, @XEvent);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure GDK_WINDOW_MINIMIZE(Window: PGdkWindowPrivate);
|
||||
const
|
||||
_NET_WM_STATE_REMOVE = 0; // remove/unset property
|
||||
@ -1228,6 +1231,48 @@ begin
|
||||
XIconifyWindow(XDisplay, XWindow, XScreenNumberOfScreen(XScreen));
|
||||
end;
|
||||
|
||||
function GDK_WINDOW_GET_MAXIMIZED(Window: PGdkWindowPrivate): gboolean;
|
||||
var
|
||||
xdisplay: PDisplay;
|
||||
xwindow: TWindow;
|
||||
|
||||
atomtype: x.TAtom;
|
||||
format: gint;
|
||||
nitems: gulong;
|
||||
bytes_after: gulong;
|
||||
state_array: pguint;
|
||||
_NET_WM_STATE,
|
||||
_NET_WM_STATE_MAXIMIZED_VERT,
|
||||
_NET_WM_STATE_MAXIMIZED_HORZ: x.TAtom;
|
||||
X: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
XWindow := GDK_WINDOW_XWINDOW (Window);
|
||||
XDisplay := GDK_WINDOW_XDISPLAY (Window);
|
||||
|
||||
_NET_WM_STATE := XInternAtom(xdisplay, '_NET_WM_STATE', false);
|
||||
_NET_WM_STATE_MAXIMIZED_VERT := XInternAtom(xdisplay, '_NET_WM_STATE_MAXIMIZED_VERT', false);
|
||||
_NET_WM_STATE_MAXIMIZED_HORZ := XInternAtom(xdisplay, '_NET_WM_STATE_MAXIMIZED_HORZ', false);
|
||||
|
||||
XGetWindowProperty (xdisplay, xwindow,
|
||||
_NET_WM_STATE,
|
||||
0, MaxInt, False, XA_ATOM, @atomtype, @format, @nitems,
|
||||
@bytes_after, gpointer(@state_array));
|
||||
|
||||
if (atomtype = XA_ATOM) and (format = 32) and (nitems > 0) then
|
||||
begin
|
||||
for X := 0 to nitems-1 do begin
|
||||
if
|
||||
(state_array[X] = _NET_WM_STATE_MAXIMIZED_VERT)
|
||||
or
|
||||
(state_array[X] = _NET_WM_STATE_MAXIMIZED_HORZ)
|
||||
then Result := True;
|
||||
|
||||
if Result then Break;
|
||||
end;
|
||||
XFree (state_array);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure GDK_WINDOW_SHOW_IN_TASKBAR(Window: PGdkWindowPrivate; Show: Boolean);
|
||||
// this is a try to hide windows from the taskbar.
|
||||
|
@ -30,7 +30,7 @@ uses
|
||||
{$IFDEF GTK2}
|
||||
Gtk2, Glib2, gdk2,
|
||||
{$ELSE}
|
||||
Gtk, gdk, Glib,
|
||||
Gtk, gdk, Glib, X, Xlib,
|
||||
{$ENDIF}
|
||||
SysUtils, Classes, LCLProc, LCLType, Controls, LMessages, InterfaceBase,
|
||||
Graphics, Dialogs,Forms, Math,
|
||||
@ -83,8 +83,11 @@ type
|
||||
|
||||
TGtkWSCustomForm = class(TWSCustomForm)
|
||||
private
|
||||
class procedure SetCallbacks(const AWinControl: TWinControl; const AWidgetInfo: PWidgetInfo); virtual;
|
||||
protected
|
||||
public
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
|
||||
|
||||
class procedure SetFormBorderStyle(const AForm: TCustomForm;
|
||||
const AFormBorderStyle: TFormBorderStyle); override;
|
||||
class procedure SetIcon(const AForm: TCustomForm; const AIcon: HICON); override;
|
||||
@ -179,6 +182,80 @@ end;
|
||||
|
||||
{ TGtkWSCustomForm }
|
||||
|
||||
{$IFDEF GTK1}
|
||||
function GtkWSFormMapEvent(Widget: PGtkWidget; WidgetInfo: PWidgetInfo): gboolean; cdecl;
|
||||
var
|
||||
Message: TLMSize;
|
||||
AForm: TCustomForm;
|
||||
begin
|
||||
Result := True;
|
||||
FillChar(Message, 0, SizeOf(Message));
|
||||
AForm := TCustomForm(WidgetInfo^.LCLObject);
|
||||
Message.Width := AForm.Width;
|
||||
Message.Height := AForm.Height;
|
||||
if WidgetInfo^.UserData <> nil then begin
|
||||
if AForm.WindowState = wsMaximized then
|
||||
WidgetSet.ShowWindow(AForm.Handle, SW_MAXIMIZE)
|
||||
else if AForm.WindowState = wsMinimized then
|
||||
WidgetSet.ShowWindow(AForm.Handle, SW_MINIMIZE);
|
||||
WidgetInfo^.UserData := nil;
|
||||
end;
|
||||
|
||||
Message.Msg := LM_SIZE;
|
||||
if GDK_WINDOW_GET_MAXIMIZED(PGdkWindowPrivate(Widget^.window)) = True then
|
||||
begin
|
||||
Message.SizeType := SIZEFULLSCREEN or Size_SourceIsInterface;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Message.SizeType := SIZENORMAL or Size_SourceIsInterface;
|
||||
end;
|
||||
|
||||
DeliverMessage(WidgetInfo^.LCLObject, Message);
|
||||
end;
|
||||
|
||||
function GtkWSFormUnMapEvent(Widget: PGtkWidget; WidgetInfo: PWidgetInfo): gboolean; cdecl;
|
||||
var
|
||||
Message: TLMSize;
|
||||
AForm: TCustomForm;
|
||||
begin
|
||||
Result := True;
|
||||
FillChar(Message, 0, SizeOf(Message));
|
||||
AForm := TCustomForm(WidgetInfo^.LCLObject);
|
||||
|
||||
Message.Msg := LM_SIZE;
|
||||
Message.SizeType := SIZEICONIC or Size_SourceIsInterface;
|
||||
Message.Width := AForm.Width;
|
||||
Message.Height := AForm.Height;
|
||||
|
||||
DeliverMessage(WidgetInfo^.LCLObject, Message);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
class procedure TGtkWSCustomForm.SetCallbacks(const AWinControl: TWinControl;
|
||||
const AWidgetInfo: PWidgetInfo);
|
||||
begin
|
||||
{$IFDEF GTK1}
|
||||
gtk_signal_connect(PGtkObject(AWidgetInfo^.CoreWidget),'map', TGtkSignalFunc(@GtkWSFormMapEvent), AWidgetInfo);
|
||||
gtk_signal_connect(PGtkObject(AWidgetInfo^.CoreWidget),'unmap', TGtkSignalFunc(@GtkWSFormUnMapEvent), AWidgetInfo);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TGtkWSCustomForm.CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): HWND;
|
||||
var
|
||||
AWidgetInfo: PWidgetInfo;
|
||||
begin
|
||||
// TODO: Move GtkInt.CreateForm to here. Somewhat complicated though because
|
||||
// it depends on several other methods from gtkint that are private.
|
||||
Result:=WidgetSet.CreateComponent(AWinControl);
|
||||
AWidgetInfo := GetWidgetInfo(Pointer(Result));
|
||||
if not (csDesigning in AWinControl.ComponentState) then
|
||||
AWidgetInfo^.UserData := Pointer(1);
|
||||
SetCallbacks(AWinControl, AWidgetInfo);
|
||||
end;
|
||||
|
||||
procedure TGtkWSCustomForm.SetFormBorderStyle(const AForm: TCustomForm;
|
||||
const AFormBorderStyle: TFormBorderStyle);
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user