diff --git a/lcl/interfaces/qt/qtint.pp b/lcl/interfaces/qt/qtint.pp index 728a062cf9..5d80c60392 100644 --- a/lcl/interfaces/qt/qtint.pp +++ b/lcl/interfaces/qt/qtint.pp @@ -266,13 +266,11 @@ type procedure MapX11Window(AWinID: LongWord); {$IFDEF QtUseAccurateFrame} function GetX11SupportedAtoms(AWinID: LongWord; AList: TStrings): boolean; - {will be used for shadow sizes and getWindowFrameSize after testing} + {Ask for _NET_FRAME_EXTENTS,_KDE_NET_WM_SHADOW,_GTK_NET_FRAME_EXTENTS} function GetX11RectForAtom(AWinID: LongWord; const AAtomName: string; out ARect: TRect): boolean; function GetX11WindowPos(AWinID: LongWord; out ALeft, ATop: integer): boolean; {check if wm supports request for frame extents} function AskX11_NET_REQUEST_FRAME_EXTENTS(AWinID: LongWord; out AMargins: TRect): boolean; - {trial to get real frame size on X11 before window is visible by using _NET_FRAME_EXTENTS} - function GetWindowFrameSize(AWinID: LongWord; out ALeft, ATop, ARight, ABottom: integer): Boolean; {$ENDIF} {$ENDIF} diff --git a/lcl/interfaces/qt/qtobject.inc b/lcl/interfaces/qt/qtobject.inc index bfbfd72f92..4c1a507dd6 100644 --- a/lcl/interfaces/qt/qtobject.inc +++ b/lcl/interfaces/qt/qtobject.inc @@ -1942,12 +1942,12 @@ begin QApplication_syncX(); end; - if not B and not GetWindowFrameSize(AID, R.Left, R.Top, R.Right, R.Bottom) then + if not B and not GetX11RectForAtom(AID, '_NET_FRAME_EXTENTS', R) then begin AId := QWidget_winID(ATempWidget); I := 0; ATicks := GetTickCount; - while not GetWindowFrameSize(AID, R.Left, R.Top, R.Right, R.Bottom) do + while not GetX11RectForAtom(AID, '_NET_FRAME_EXTENTS', R) do begin QApplication_syncX(); QCoreApplication_processEvents; diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index c79017efd7..4651a82c06 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -7363,9 +7363,10 @@ begin R := QtWidgetSet.WSFrameMargins; if (R.Left = 0) and (R.Top = 0) and (R.Bottom = 0) and (R.Right = 0) then begin - GetWindowFrameSize(QWidget_winID(Widget), R.Left, R.Top, R.Right, R.Bottom); + GetX11RectForAtom(QWidget_winID(Widget),'_NET_FRAME_EXTENTS', R); QtWidgetSet.WSFrameMargins := R; FrameMargins := R; + DebugLn('WARNING: TQtMainWindow.EventFilter('+dbgsName(LCLObject)+') setting widgetset frame margins to '+dbgs(R)+' from form activation !'); end else begin if QX11Info_isCompositingManagerRunning then diff --git a/lcl/interfaces/qt/qtx11.inc b/lcl/interfaces/qt/qtx11.inc index 89c42c6f7d..cf58c418a9 100644 --- a/lcl/interfaces/qt/qtx11.inc +++ b/lcl/interfaces/qt/qtx11.inc @@ -375,76 +375,6 @@ begin Result := (AXWinAttr.map_installed > 0) and (AXWinAttr.map_state = 2); end; -function GetWindowFrameSize(AWinID: LongWord; out ALeft, ATop, ARight, - ABottom: integer): Boolean; -var - Display: PDisplay; - X11Window: TWindow; - WMAtom: TAtom; - typeReturned: TAtom; - formatReturned: Integer; - nitemsReturned: PtrInt; - unused: PtrInt; - data: Pointer; - ANewData: PUInt32; -begin - - Result := False; - Display := QX11Info_display(); - ALeft := 0; - ATop := 0; - ARight := 0; - ABottom := 0; - if Display = nil then - exit; - - X11Window := TWindow(AWinID); - if X11Window = 0 then - exit; - - {TODO: compositing wm must provide shadow decorations _KDE_NET_WM_SHADOW, find others} - WMAtom := XInternAtom(Display,'_NET_FRAME_EXTENTS', True); - if WMAtom > 0 then - begin - data := nil; - if XGetWindowProperty(Display, X11Window, WMAtom, 0, 4, False, XA_CARDINAL, - @typeReturned, @formatReturned, @nitemsReturned, - @unused, @data) = Success then - begin - if (typeReturned = XA_CARDINAL) and (formatReturned = 32) and - (Data <> nil) then - begin - ANewData := Data; - while nitemsReturned > 0 do - begin - if ALeft = 0 then - ALeft := Integer(ANewData^) - else - if ARight = 0 then - ARight := Integer(ANewData^) - else - if ATop = 0 then - ATop := Integer(ANewData^) - else - if ABottom = 0 then - ABottom := Integer(ANewData^); - dec(nItemsReturned); - if Result or (nItemsReturned = 0) then - break; - inc(ANewData); - end; - Result := True; - if nitemsReturned > 0 then - XFree(Data); - Data := nil; - end; - end; - end else - begin - DebugLn('QtLCL error: "'+GetWindowManager+'" wm does not support _NET_FRAME_EXTENTS (1).'); - end; -end; - var InternalExtentsAtom: TAtom = 0; {find extents atom} InternalExtentsCounter: Integer = 0; {counter for bad wm, eg for blackbox} @@ -517,7 +447,7 @@ begin if XIfEvent(d, @ReturnEvent, @propNotifyFrameExtents, TXPointer(@AWinID)) = Success then begin - Result := GetWindowFrameSize(AWinID, AMargins.Left, AMargins.Top, AMargins.Right, AMargins.Bottom); + Result := GetX11RectForAtom(AWinID, '_NET_FRAME_EXTENTS', AMargins); if not Result and (InternalExtentsCounter = -BadImplementation) then begin DebugLn('QtLCL WARNING: "'+GetWindowManager+'" wm bad implementation of _NET_REQUEST_FRAME_EXTENTS.');