Qt: use local variable instead of casting, fixed weird behaviour of modal and borderless modal windows with newer versions of metacity wm.

git-svn-id: trunk@57880 -
This commit is contained in:
zeljko 2018-05-10 09:10:58 +00:00
parent adb7170dbf
commit ea1d69a461

View File

@ -429,6 +429,7 @@ var
W: QWidgetH;
{$ENDIF}
Flags: Cardinal;
ACustomForm: TCustomForm;
function ShowNonModalOverModal: Boolean;
var
@ -470,15 +471,16 @@ begin
if not WSCheckHandleAllocated(AWinControl, 'ShowHide') then
Exit;
ACustomForm := TCustomForm(AWinControl);
Widget := TQtMainWindow(AWinControl.Handle);
if AWinControl.HandleObjectShouldBeVisible then
begin
if fsModal in TForm(AWinControl).FormState then
if fsModal in ACustomForm.FormState then
begin
{$ifdef MSWINDOWS}
// qt doesn't modal windows as QtTool.see issue #18709
if (TForm(AWinControl).BorderStyle in [bsToolWindow, bsSizeToolWin]) then
if (ACustomForm.BorderStyle in [bsToolWindow, bsSizeToolWin]) then
QWidget_setWindowFlags(Widget.Widget, QtDialog);
if QApplication_activeModalWidget <> nil then
QWidget_setParent(Widget.Widget, QApplication_activeModalWidget);
@ -505,33 +507,34 @@ begin
end;
end;
end;
QWidget_setParent(Widget.Widget, W);
if GetEnvironmentVariable('XDG_CURRENT_DESKTOP') = '' then
QWidget_setParent(Widget.Widget, W);
end else
QWidget_setParent(Widget.Widget, QApplication_desktop());
{$endif}
if TCustomForm(AWinControl).BorderStyle <> bsNone then
if ACustomForm.BorderStyle <> bsNone then
begin
QWidget_setWindowFlags(Widget.Widget, QtDialog or
{$ifdef darwin}
QtWindowSystemMenuHint or
{$endif}
GetQtBorderIcons(TCustomForm(AWinControl).BorderStyle,
TCustomForm(AWinControl).BorderIcons));
GetQtBorderIcons(ACustomForm.BorderStyle,
ACustomForm.BorderIcons));
end;
Widget.setWindowModality(QtApplicationModal);
end;
if TForm(AWinControl).FormStyle = fsMDIChild then
if ACustomForm.FormStyle = fsMDIChild then
begin
{MDI windows have to be resized , since titlebar is included into widget geometry !}
if not (csDesigning in AWinControl.ComponentState)
and not Widget.isMaximized then
begin
QWidget_contentsRect(Widget.Widget, @R);
R.Right := TForm(AWinControl).Width + R.Left;
R.Bottom := TForm(AWinControl).Height + R.Top;
R.Right := ACustomForm.Width + R.Left;
R.Bottom := ACustomForm.Height + R.Top;
R.Left := Widget.MdiChildCount * 10;
R.Top := Widget.MdiChildCount * 10;
Widget.move(R.Left, R.Top);
@ -539,14 +542,14 @@ begin
end;
end;
if (TForm(AWinControl).FormStyle <> fsMDIChild) or
if (ACustomForm.FormStyle <> fsMDIChild) or
(csDesigning in AWinControl.ComponentState) then
begin
if (csDesigning in AWinControl.ComponentState) and
(TCustomForm(AWinControl).WindowState = wsMaximized) then
(ACustomForm.WindowState = wsMaximized) then
Widget.setWindowState(LCLToQtWindowState[wsNormal])
else
Widget.setWindowState(LCLToQtWindowState[TCustomForm(AWinControl).WindowState]);
Widget.setWindowState(LCLToQtWindowState[ACustomForm.WindowState]);
end;
end;
@ -557,7 +560,7 @@ begin
// issue #12459
else
if AWinControl.HandleObjectShouldBeVisible
and (TCustomForm(AWinControl).FormStyle in fsAllStayOnTop) then
and (ACustomForm.FormStyle in fsAllStayOnTop) then
begin
Flags := Widget.windowFlags;
if (Flags and QtWindowStaysOnTopHint = 0) then
@ -566,14 +569,14 @@ begin
Widget.setWindowFlags(Flags);
end;
if not Assigned(AWinControl.Parent) and
not (fsModal in TForm(AWinControl).FormState) and
(TForm(AWinControl).FormStyle <> fsMDIChild) and
not (fsModal in ACustomForm.FormState) and
(ACustomForm.FormStyle <> fsMDIChild) and
(QApplication_activeModalWidget() <> nil) then
TQtMainWindow(Widget).setRealPopupParent(
QApplication_activeModalWidget());
end else
begin
if (TCustomForm(AWinControl).FormStyle in fsAllStayOnTop) then
if (ACustomForm.FormStyle in fsAllStayOnTop) then
begin
if not (csDestroying in AWinControl.ComponentState) then
begin
@ -585,11 +588,11 @@ begin
{$IFDEF HASX11}
// issue #26018
if AWinControl.HandleObjectShouldBeVisible and
not (TCustomForm(AWinControl).FormStyle in fsAllStayOnTop) and
not (fsModal in TCustomForm(AWinControl).FormState) and
(TCustomForm(AWinControl).FormStyle <> fsMDIChild) then
not (ACustomForm.FormStyle in fsAllStayOnTop) and
not (fsModal in ACustomForm.FormState) and
(ACustomForm.FormStyle <> fsMDIChild) then
begin
APopupParent := TCustomForm(AWinControl).GetRealPopupParent;
APopupParent := ACustomForm.GetRealPopupParent;
if (APopupParent <> nil) then
begin
Widget.setParent(TQtWidget(APopupParent.Handle).Widget);
@ -609,24 +612,25 @@ begin
QCoreApplication_processEvents(QEventLoopAllEvents);
if (Application.TaskBarBehavior = tbSingleButton) or
(TForm(AWinControl).ShowInTaskBar <> stDefault) then
SetShowInTaskbar(TForm(AWinControl), TForm(AWinControl).ShowInTaskBar);
(ACustomForm.ShowInTaskBar <> stDefault) then
SetShowInTaskbar(ACustomForm, ACustomForm.ShowInTaskBar);
if AWinControl.HandleObjectShouldBeVisible and
not (csDesigning in TForm(AWinControl).ComponentState) and
(TForm(AWinControl).FormStyle <> fsMDIChild) then
not (csDesigning in ACustomForm.ComponentState) and
(ACustomForm.FormStyle <> fsMDIChild) then
begin
if (fsModal in TForm(AWinControl).FormState) then
if (fsModal in ACustomForm.FormState) then
begin
if (Application.TaskBarBehavior <> tbSingleButton) then
begin
SetSkipX11Taskbar(Widget.Widget, True);
Widget.setShowInTaskBar(False);
end;
if (QtWidgetSet.WindowManagerName = 'metacity') then
X11Raise(QWidget_winID(Widget.Widget));
if (ACustomForm.BorderStyle <> bsNone) and
(QtWidgetSet.WindowManagerName = 'metacity') then
X11Raise(QWidget_winID(Widget.Widget));
end else
if (TForm(AWinControl).FormStyle = fsSplash) then
if (ACustomForm.FormStyle = fsSplash) then
begin
QWidget_repaint(Widget.GetContainerWidget);
QCoreApplication_processEvents(QEventLoopExcludeUserInputEvents);