From 9f1e2fbd9cf5fad6abaa50ec70b3f1f3e2d7df89 Mon Sep 17 00:00:00 2001 From: zeljko Date: Wed, 2 Feb 2011 12:03:22 +0000 Subject: [PATCH] Qt: fixed weird frameGeometry behaviour under X11, as explained here http://doc.qt.nokia.com/4.7/application-windows.html#window-geometry issue #18658 git-svn-id: trunk@29330 - --- lcl/interfaces/qt/qtwidgets.pas | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index 1728a4df62..39e0d72cf1 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -3043,7 +3043,7 @@ end; procedure TQtWidget.SlotMove(Event: QEventH); cdecl; var Msg: TLMMove; - Pos: TQtPoint; + APos, ACurrPos: TQtPoint; FrameRect, WindowRect: TRect; begin {$ifdef VerboseQt} @@ -3068,12 +3068,27 @@ begin Msg.MoveType := Msg.MoveType or Move_SourceIsInterface; - Pos := QMoveEvent_pos(QMoveEventH(Event))^; + APos := QMoveEvent_pos(QMoveEventH(Event))^; FrameRect := getFrameGeometry; WindowRect := getGeometry; - Msg.XPos := Pos.x - (WindowRect.Left - FrameRect.Left); - Msg.YPos := Pos.y - (WindowRect.Top - FrameRect.Top); + // here is explanation why frameGeometry sometimes + // doesn't return correct results under X11 + // http://doc.qt.nokia.com/4.7/application-windows.html#window-geometry + // issue #18658 + {$IFDEF HASX11} + if (LCLObject is TCustomForm) and EqualRect(FrameRect, WindowRect) and + (TCustomForm(LCLObject).BorderStyle <> bsNone) and + not (TCustomForm(LCLObject).FormStyle in [fsMDIChild,fsSplash]) then + begin + ACurrPos := getPos; + if (ACurrPos.X = WindowRect.Left) and (ACurrPos.Y = WindowRect.Top) then + OffsetRect(FrameRect,-WindowRect.Left,-WindowRect.Top); + end; + {$ENDIF} + + Msg.XPos := APos.x - (WindowRect.Left - FrameRect.Left); + Msg.YPos := APos.y - (WindowRect.Top - FrameRect.Top); DeliverMessage(Msg); end;