From 36c1a482a02e1a2ef105550acdf040c33a3db529 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 17 May 2017 23:10:40 +0000 Subject: [PATCH] lcl: gtk2: fixed shrinking designer form, bug #31832, patch Kostas Michalopoulos git-svn-id: trunk@54958 - --- lcl/interfaces/gtk2/gtk2winapi.inc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lcl/interfaces/gtk2/gtk2winapi.inc b/lcl/interfaces/gtk2/gtk2winapi.inc index dc0e4a9496..2b8ddfd908 100644 --- a/lcl/interfaces/gtk2/gtk2winapi.inc +++ b/lcl/interfaces/gtk2/gtk2winapi.inc @@ -9400,6 +9400,7 @@ var GtkWindow: PGtkWindow; B: Boolean; Widget: PGtkWidget; + Control: TWinControl; begin Result := False; @@ -9446,7 +9447,18 @@ begin if not GTK_WIDGET_VISIBLE(PGtkWidget(GtkWindow)) then gtk_widget_show(PGtkWidget(GtkWindow)); gtk_window_deiconify(GtkWindow); - gtk_window_unmaximize(GtkWindow); + // Workaround for gtk2 bug with some window managers: + // calling gtk_window_unmaximize when the window is not maximized + // will cause window to shrink. Here we check if the window we are + // resizing is a form and use its WindowState property to make sure + // it is maximized before trying to unmaximize it which avoids the + // issue (custom code that uses the Win32 API will still have the + // problem though, but gtk2 does not offer a is_maximized method) + // see https://bugs.freepascal.org/view.php?id=31832 + Control:=TWinControl(GetLCLObject({%H-}Pointer(hWnd))); + if (not (Control is TCustomForm)) or + (TCustomForm(Control).WindowState=wsMaximized) then + gtk_window_unmaximize(GtkWindow); gtk_window_unfullscreen(GtkWindow); end; end;