LCL-Gtk2: Keep window stack relationship when a modal/hint window is closed. Patch by Alexander (Rouse_) Bagel, issue #41731.

This commit is contained in:
Maxim Ganetsky 2025-06-27 20:42:10 +03:00
parent 854bdb0007
commit e43acbc75e
3 changed files with 38 additions and 1 deletions

View File

@ -493,6 +493,7 @@ type
FormBorderStyle: Integer; // used only by forms
FormWindowState: TGdkEventWindowState; // used only by forms to stop infinite loops eg. issue #16505
FirstPaint: boolean; // for accurate frame - forms only
WndParent: HWnd;
end;
//TODO: remove

View File

@ -4176,6 +4176,7 @@ begin
Result^.Style := AParams.Style;
Result^.ExStyle := AParams.ExStyle;
Result^.WndProc := {%H-}PtrUInt(AParams.WindowClass.lpfnWndProc);
Result^.WndParent := AParams.WndParent;
end;
function GetWidgetInfo(const AWidget: Pointer): PWidgetInfo;

View File

@ -2073,6 +2073,8 @@ var
ATransientWindow2: PTransientWindow;
ParentTransientWindow: PTransientWindow;
OldTransientParent: PGtkWindow;
WidgetInfo: PWidgetInfo;
WndParentPresent: Boolean;
begin
if (not UseTransientForModalWindows) then exit;
if UpdatingTransientWindows then begin
@ -2161,11 +2163,44 @@ begin
// there is no modal window
// -> break all transient window relation ships
for i:=AllWindows.Count-1 downto 0 do begin
ATransientWindow:=PTransientWindow(AllWindows[i]);
ATransientWindow := PTransientWindow(AllWindows[i]);
{$IFDEF VerboseTransient}
debugln(['TGtk2WidgetSet.UpdateTransientWindows Untransient ',i,
' ',dbgsname(ATransientWindow^.Component)]);
{$ENDIF}
LCLObject := ATransientWindow^.Component;
if LCLObject is TCustomForm then
begin
if TCustomForm(LCLObject).PopupParent <> nil then
begin
gtk_window_set_transient_for(ATransientWindow^.GtkWindow,
{%H-}PGtkWindow(TCustomForm(LCLObject).PopupParent.Handle));
Continue;
end
else
begin
WidgetInfo := GetWidgetInfo(ATransientWindow^.GtkWindow);
Window := {%H-}PGtkWindow(WidgetInfo^.WndParent);
if Window <> nil then
begin
WndParentPresent := False;
for j := 0 to AllWindows.Count - 1 do
begin
ATransientWindow2 := PTransientWindow(AllWindows[j]);
if ATransientWindow2^.GtkWindow = Window then
begin
WndParentPresent := True;
gtk_window_set_transient_for(ATransientWindow^.GtkWindow, Window);
Break;
end;
end;
if WndParentPresent then
Continue
else
WidgetInfo^.WndParent := 0;
end;
end;
end;
gtk_window_set_transient_for(ATransientWindow^.GtkWindow,nil);
end;
end else begin