From 0cc1dc98eb430489f1f7e4712dd9552183493264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDeljan=20Rikalo?= Date: Wed, 23 Aug 2023 09:09:06 +0200 Subject: [PATCH] Gtk2: do not create dummy widget if WM name is empty, also reduce looping on slow systems. issue #40413 (cherry picked from commit e2f0b349f4eb7645782f9052c3bb984199589615) --- lcl/interfaces/gtk2/gtk2widgetset.inc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lcl/interfaces/gtk2/gtk2widgetset.inc b/lcl/interfaces/gtk2/gtk2widgetset.inc index 0c3df25736..f30b00f033 100644 --- a/lcl/interfaces/gtk2/gtk2widgetset.inc +++ b/lcl/interfaces/gtk2/gtk2widgetset.inc @@ -1895,8 +1895,12 @@ function TGtk2WidgetSet.CreateDummyWidgetFrame(const ALeft, ATop, AWidth, AHeight: integer): boolean; var ADummy: TDummyWidget; + WM: String; begin Result := False; + WM := GetWindowManager; + if (WM = '') or (WM = 'wayland') then + exit; ADummy := TDummyWidget.Create; ADummy.ShowDummyWidget(ALeft, ATop, AWidth, AHeight); FWSFrameRect := ADummy.GetWidgetFrame; @@ -4584,7 +4588,7 @@ begin @unused, @data) = Success then begin if (typeReturned = WMAtom) and (formatReturned = 8) then - Result := LowerCase(StrPas(PWideChar(Data))); + Result := LowerCase(StrPas(PChar(Data))); if Data <> nil then XFree(Data); Data := nil; @@ -6610,9 +6614,9 @@ begin if Result then begin if Gtk2WidgetSet.compositeManagerRunning then - AMaxLoops := 200000 + AMaxLoops := 100000 else - AMaxLoops := 20000; + AMaxLoops := 10000; {$IFDEF DEBUGGTK2FRAMESIZE} writeln('ShowDummyWidget(start) WindowManager="',Gtk2WidgetSet.GetWindowManager,'" Compositing enabled="',Gtk2WidgetSet.compositeManagerRunning,'" IsWayland="UNKNOWN" MaxLoops=',AMaxLoops); ATicks := GetTickCount64;