View Issue Details

IDProjectCategoryView StatusLast Update
0029253LazarusLCLpublic2015-12-27 10:29
ReporterOndrej PokornyAssigned ToZeljan Rikalo 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.7 (SVN)Product Buildtrunk 
Target Version1.6Fixed in Version1.7 (SVN) 
Summary0029253: Qt: when dialog with PopupParent is shown and you select another form (not PopupParent), the dialog is hidden
DescriptionHave MainForm, Form2 and Dlg.

Form2 is non-modal and has no parent window.
Dlg is non-modal and has parent window set to Form2.

When you activate (focus) MainForm, Dlg gets completely hidden.
Steps To ReproduceRun the following code:

procedure TForm1.BitBtn2Click(Sender: TObject);
var
  Dlg, Form2: TForm;
begin
  Form2 := TForm.CreateNew(Self);
  Form2.Position := poDesigned;
  Form2.Left := 0;
  Form2.Top := 0;
  Form2.Show;

  Dlg := TForm.CreateNew(Self);
  Dlg.Position := poDesigned;
  Dlg.Left := Left div 2;
  Dlg.Top := Top div 2;
  Dlg.PopupMode := pmExplicit;
  Dlg.PopupParent := Form2;
  Dlg.Show;
end;

And then click on MainForm (TForm1). Dlg gets hidden. Click on Form2, Dlg is shown.
Additional InformationOnly Qt defected. win32 and Gtk2 behave correctly. I tested on Linux/KDE.

It is not a regression from r51032.
TagsNo tags attached.
Fixed in Revision51046,51047
LazTarget-
WidgetsetQT
Attached Files
  • qttransientaspopupparent.diff (2,037 bytes)
    Index: lcl/interfaces/qt/qtx11.inc
    ===================================================================
    --- lcl/interfaces/qt/qtx11.inc	(revision 51044)
    +++ lcl/interfaces/qt/qtx11.inc	(working copy)
    @@ -214,6 +214,25 @@
       end;
     end;
     
    +function SetTransientForHint(Widget: QWidgetH; ATransientWin: QWidgetH): boolean;
    +var
    +   Display: PDisplay;
    +   AWin: LongWord;
    +begin
    +  Result := False;
    +  if Widget = nil then
    +    exit;
    +  Display := QX11Info_display();
    +
    +  if Display = nil then
    +    exit;
    +  if ATransientWin <> nil then
    +    AWin := QWidget_winID(ATransientWin)
    +  else
    +    AWin := 0;
    +  Result := XSetTransientForHint(Display, QWidget_winId(Widget), AWin) = 1;
    +end;
    +
     procedure SetSkipX11Taskbar(Widget: QWidgetH; const ASkipTaskBar: Boolean);
     const
       _NET_WM_STATE_REMOVE = 0;
    Index: lcl/interfaces/qt/qtwsforms.pp
    ===================================================================
    --- lcl/interfaces/qt/qtwsforms.pp	(revision 51044)
    +++ lcl/interfaces/qt/qtwsforms.pp	(working copy)
    @@ -548,7 +548,8 @@
             begin
               Flags := Widget.windowFlags;
               Widget.setParent(TQtWidget(APopupParent.Handle).Widget);
    -          Widget.setWindowFlags(Flags or QtTool);
    +          // Widget.setWindowFlags(Flags or QtTool);
    +          SetTransientForHint(Widget.Widget, TQtWidget(APopupParent.Handle).Widget);
             end;
           end;
           {$ENDIF}
    Index: lcl/interfaces/qt/qtint.pp
    ===================================================================
    --- lcl/interfaces/qt/qtint.pp	(revision 51044)
    +++ lcl/interfaces/qt/qtint.pp	(working copy)
    @@ -246,6 +246,7 @@
       function X11Raise(AHandle: HWND): boolean;
       function X11GetActiveWindow: QWidgetH;
       function GetWindowManager: String;
    +  function SetTransientForHint(Widget: QWidgetH; ATransientWin: QWidgetH): boolean;
       procedure SetSkipX11Taskbar(Widget: QWidgetH; const ASkipTaskBar: Boolean);
       {check if XWindow have _NET_WM_STATE_ABOVE and our form doesn''t know anything about it}
       function GetAlwaysOnTopX11(Widget: QWidgetH): boolean;
    

Activities

Zeljan Rikalo

2015-12-26 20:34

developer  

qttransientaspopupparent.diff (2,037 bytes)
Index: lcl/interfaces/qt/qtx11.inc
===================================================================
--- lcl/interfaces/qt/qtx11.inc	(revision 51044)
+++ lcl/interfaces/qt/qtx11.inc	(working copy)
@@ -214,6 +214,25 @@
   end;
 end;
 
+function SetTransientForHint(Widget: QWidgetH; ATransientWin: QWidgetH): boolean;
+var
+   Display: PDisplay;
+   AWin: LongWord;
+begin
+  Result := False;
+  if Widget = nil then
+    exit;
+  Display := QX11Info_display();
+
+  if Display = nil then
+    exit;
+  if ATransientWin <> nil then
+    AWin := QWidget_winID(ATransientWin)
+  else
+    AWin := 0;
+  Result := XSetTransientForHint(Display, QWidget_winId(Widget), AWin) = 1;
+end;
+
 procedure SetSkipX11Taskbar(Widget: QWidgetH; const ASkipTaskBar: Boolean);
 const
   _NET_WM_STATE_REMOVE = 0;
Index: lcl/interfaces/qt/qtwsforms.pp
===================================================================
--- lcl/interfaces/qt/qtwsforms.pp	(revision 51044)
+++ lcl/interfaces/qt/qtwsforms.pp	(working copy)
@@ -548,7 +548,8 @@
         begin
           Flags := Widget.windowFlags;
           Widget.setParent(TQtWidget(APopupParent.Handle).Widget);
-          Widget.setWindowFlags(Flags or QtTool);
+          // Widget.setWindowFlags(Flags or QtTool);
+          SetTransientForHint(Widget.Widget, TQtWidget(APopupParent.Handle).Widget);
         end;
       end;
       {$ENDIF}
Index: lcl/interfaces/qt/qtint.pp
===================================================================
--- lcl/interfaces/qt/qtint.pp	(revision 51044)
+++ lcl/interfaces/qt/qtint.pp	(working copy)
@@ -246,6 +246,7 @@
   function X11Raise(AHandle: HWND): boolean;
   function X11GetActiveWindow: QWidgetH;
   function GetWindowManager: String;
+  function SetTransientForHint(Widget: QWidgetH; ATransientWin: QWidgetH): boolean;
   procedure SetSkipX11Taskbar(Widget: QWidgetH; const ASkipTaskBar: Boolean);
   {check if XWindow have _NET_WM_STATE_ABOVE and our form doesn''t know anything about it}
   function GetAlwaysOnTopX11(Widget: QWidgetH): boolean;

Zeljan Rikalo

2015-12-26 20:36

developer   ~0088289

Last edited: 2015-12-26 20:59

View 2 revisions

@Ondrej, pls test with attached patch. Note, that I've created pure X11 implementation to get around of Qt QtTool behaviour. It seem that it works as gtk2 now. This should be tested with many scenarios before commiting (eg. popup over modal form etc).

Ondrej Pokorny

2015-12-27 09:19

reporter   ~0088292

@Zeljan: thanks. It works well on my Kubuntu/KDE system.

>> This should be tested with many scenarios before commiting.
Although not a regression from your patch: 0029260
+ I let you to decide when to commit.

Zeljan Rikalo

2015-12-27 09:47

developer   ~0088296

r51046 - added x11 function, still waiting for your feedback for 0029260 (my last note about setting PopupMode := pmNone for modal window).

Zeljan Rikalo

2015-12-27 10:15

developer   ~0088299

Please test and close if ok.

Ondrej Pokorny

2015-12-27 10:29

reporter   ~0088301

Works well, thanks. I changed Target Version to 1.6.

Issue History

Date Modified Username Field Change
2015-12-25 17:08 Ondrej Pokorny New Issue
2015-12-26 20:34 Zeljan Rikalo Assigned To => Zeljan Rikalo
2015-12-26 20:34 Zeljan Rikalo Status new => assigned
2015-12-26 20:34 Zeljan Rikalo File Added: qttransientaspopupparent.diff
2015-12-26 20:36 Zeljan Rikalo Note Added: 0088289
2015-12-26 20:36 Zeljan Rikalo Status assigned => feedback
2015-12-26 20:59 Zeljan Rikalo Note Edited: 0088289 View Revisions
2015-12-27 08:56 Ondrej Pokorny File Added: test-with-modal.zip
2015-12-27 09:02 Ondrej Pokorny File Deleted: test-with-modal.zip
2015-12-27 09:02 Ondrej Pokorny File Added: test-with-modal.zip
2015-12-27 09:04 Ondrej Pokorny File Deleted: test-with-modal.zip
2015-12-27 09:04 Ondrej Pokorny File Added: test-with-modal.zip
2015-12-27 09:06 Ondrej Pokorny File Added: test-with-modal.png
2015-12-27 09:10 Ondrej Pokorny File Deleted: test-with-modal.zip
2015-12-27 09:10 Ondrej Pokorny File Deleted: test-with-modal.png
2015-12-27 09:19 Ondrej Pokorny Note Added: 0088292
2015-12-27 09:19 Ondrej Pokorny Status feedback => assigned
2015-12-27 09:47 Zeljan Rikalo Note Added: 0088296
2015-12-27 10:15 Zeljan Rikalo Fixed in Revision => 51046,51047
2015-12-27 10:15 Zeljan Rikalo Note Added: 0088299
2015-12-27 10:15 Zeljan Rikalo Status assigned => resolved
2015-12-27 10:15 Zeljan Rikalo Resolution open => fixed
2015-12-27 10:29 Ondrej Pokorny Note Added: 0088301
2015-12-27 10:29 Ondrej Pokorny Status resolved => closed
2015-12-27 10:29 Ondrej Pokorny Fixed in Version => 1.7 (SVN)
2015-12-27 10:29 Ondrej Pokorny Target Version 1.8 => 1.6