View Issue Details

IDProjectCategoryView StatusLast Update
0025589LazarusLCLpublic2015-04-10 10:22
ReporterMaciej IzakAssigned ToZeljan Rikalo 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.3 (SVN)Product Build 
Target Version1.4Fixed in Version1.5 (SVN) 
Summary0025589: PopupParent don't work (Qt and GTK2)
DescriptionPopupParent don't work in Qt and GTK2. In Windows all is ok.
Steps To ReproduceLook at attached demo. Click on Button1 and select Form1. Form1 will be on the top of Form2! :(
TagsNo tags attached.
Fixed in Revision48692,48693
LazTarget1.4
WidgetsetGTK 2, QT
Attached Files
  • r29.zip (100,944 bytes)
  • qt_explicit_popupparent.diff (889 bytes)
    Index: lcl/interfaces/qt/qtwidgets.pas
    ===================================================================
    --- lcl/interfaces/qt/qtwidgets.pas	(revision 48684)
    +++ lcl/interfaces/qt/qtwidgets.pas	(working copy)
    @@ -6696,9 +6696,19 @@
           if Screen.ActiveForm <> nil then
             NewParent := TQtWidget(Screen.ActiveForm.Handle).Widget;
         pmExplicit:
    +    begin
           // parent is FPopupParent
           if FPopupParent <> nil then
    -        NewParent := FPopupParent;
    +        NewParent := FPopupParent
    +      else
    +      begin
    +        if not IsMainForm then
    +        begin
    +          NewParent := TQtMainWindow(Application.MainForm.Handle).Widget;
    +          setWindowFlags(windowFlags or QtSheet);
    +        end;
    +      end;
    +    end;
       end;
       if (NewParent = nil) and not FShowOnTaskBar and not IsMainForm then
         NewParent := TQtMainWindow(Application.MainForm.Handle).Widget;
    
  • gtk2_explicit_popupparent.diff (1,158 bytes)
    Index: lcl/interfaces/gtk2/gtk2wsforms.pp
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2wsforms.pp	(revision 48684)
    +++ lcl/interfaces/gtk2/gtk2wsforms.pp	(working copy)
    @@ -775,6 +775,16 @@
                 gtk_window_set_keep_above(GtkWindow, True);
           end;
         end;
    +
    +    if AWinControl.HandleObjectShouldBeVisible and
    +      not (csDesigning in AForm.ComponentState) and
    +      not (AForm.FormStyle in fsAllStayOnTop) and
    +      not (fsModal in AForm.FormState) and
    +      (AForm.PopupMode = pmExplicit) and
    +      (AForm.PopupParent = nil) then
    +    begin
    +      SetPopupParent(AForm, AForm.PopupMode, AForm.PopupParent);
    +    end;
         {$ENDIF}
     
         Gtk2WidgetSet.SetVisible(AWinControl, AForm.HandleObjectShouldBeVisible);
    @@ -846,7 +856,11 @@
         pmAuto:
           PopupParent := Screen.ActiveForm;
         pmExplicit:
    +    begin
           PopupParent := APopupParent;
    +      if PopupParent = nil then
    +        PopupParent := Application.MainForm;
    +    end;
       end;
       if PopupParent <> nil then
         gtk_window_set_transient_for({%H-}PGtkWindow(ACustomForm.Handle), {%H-}PGtkWindow(PopupParent.Handle))
    

Activities

Maciej Izak

2014-01-24 21:51

developer  

r29.zip (100,944 bytes)

Zeljan Rikalo

2015-04-09 11:07

developer  

qt_explicit_popupparent.diff (889 bytes)
Index: lcl/interfaces/qt/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt/qtwidgets.pas	(revision 48684)
+++ lcl/interfaces/qt/qtwidgets.pas	(working copy)
@@ -6696,9 +6696,19 @@
       if Screen.ActiveForm <> nil then
         NewParent := TQtWidget(Screen.ActiveForm.Handle).Widget;
     pmExplicit:
+    begin
       // parent is FPopupParent
       if FPopupParent <> nil then
-        NewParent := FPopupParent;
+        NewParent := FPopupParent
+      else
+      begin
+        if not IsMainForm then
+        begin
+          NewParent := TQtMainWindow(Application.MainForm.Handle).Widget;
+          setWindowFlags(windowFlags or QtSheet);
+        end;
+      end;
+    end;
   end;
   if (NewParent = nil) and not FShowOnTaskBar and not IsMainForm then
     NewParent := TQtMainWindow(Application.MainForm.Handle).Widget;

Zeljan Rikalo

2015-04-09 11:08

developer   ~0082739

Attached is qt patch for explicit mode. Works ok on X11 - we do not use QtTool which changes title bar, but QtSheet which does exactly what it should be.
Must be tested on windows and mac before applying. Patch is here just as remainder for me.

Zeljan Rikalo

2015-04-09 11:19

developer  

gtk2_explicit_popupparent.diff (1,158 bytes)
Index: lcl/interfaces/gtk2/gtk2wsforms.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wsforms.pp	(revision 48684)
+++ lcl/interfaces/gtk2/gtk2wsforms.pp	(working copy)
@@ -775,6 +775,16 @@
             gtk_window_set_keep_above(GtkWindow, True);
       end;
     end;
+
+    if AWinControl.HandleObjectShouldBeVisible and
+      not (csDesigning in AForm.ComponentState) and
+      not (AForm.FormStyle in fsAllStayOnTop) and
+      not (fsModal in AForm.FormState) and
+      (AForm.PopupMode = pmExplicit) and
+      (AForm.PopupParent = nil) then
+    begin
+      SetPopupParent(AForm, AForm.PopupMode, AForm.PopupParent);
+    end;
     {$ENDIF}
 
     Gtk2WidgetSet.SetVisible(AWinControl, AForm.HandleObjectShouldBeVisible);
@@ -846,7 +856,11 @@
     pmAuto:
       PopupParent := Screen.ActiveForm;
     pmExplicit:
+    begin
       PopupParent := APopupParent;
+      if PopupParent = nil then
+        PopupParent := Application.MainForm;
+    end;
   end;
   if PopupParent <> nil then
     gtk_window_set_transient_for({%H-}PGtkWindow(ACustomForm.Handle), {%H-}PGtkWindow(PopupParent.Handle))

Zeljan Rikalo

2015-04-09 11:20

developer   ~0082741

gtk2 patch attached too. Fixes pmExplicit popupParent under X11.

Zeljan Rikalo

2015-04-09 14:41

developer   ~0082747

Keep in mind: Provided example isn't good lazarus project. lpi is missing, also units should be added to the project, forms of units opened and then saved because pure build does not work (something is wrong with lfm I guess).

Zeljan Rikalo

2015-04-10 10:22

developer   ~0082771

Please test and close if ok.

Issue History

Date Modified Username Field Change
2014-01-24 21:51 Maciej Izak New Issue
2014-01-24 21:51 Maciej Izak File Added: r29.zip
2015-04-07 17:39 Zeljan Rikalo Assigned To => Zeljan Rikalo
2015-04-07 17:39 Zeljan Rikalo Status new => assigned
2015-04-07 17:48 Zeljan Rikalo LazTarget => -
2015-04-07 17:48 Zeljan Rikalo Status assigned => confirmed
2015-04-09 11:07 Zeljan Rikalo File Added: qt_explicit_popupparent.diff
2015-04-09 11:08 Zeljan Rikalo Note Added: 0082739
2015-04-09 11:19 Zeljan Rikalo File Added: gtk2_explicit_popupparent.diff
2015-04-09 11:20 Zeljan Rikalo Note Added: 0082741
2015-04-09 14:41 Zeljan Rikalo Note Added: 0082747
2015-04-10 10:22 Zeljan Rikalo Fixed in Revision => 48692,48693
2015-04-10 10:22 Zeljan Rikalo LazTarget - => 1.4
2015-04-10 10:22 Zeljan Rikalo Note Added: 0082771
2015-04-10 10:22 Zeljan Rikalo Status confirmed => resolved
2015-04-10 10:22 Zeljan Rikalo Fixed in Version => 1.5 (SVN)
2015-04-10 10:22 Zeljan Rikalo Resolution open => fixed
2015-04-10 10:22 Zeljan Rikalo Target Version => 1.4