mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 07:19:18 +02:00
Qt: simplified x11 calls.
git-svn-id: trunk@51855 -
This commit is contained in:
parent
8085593af3
commit
76e8f6c853
@ -266,13 +266,11 @@ type
|
|||||||
procedure MapX11Window(AWinID: LongWord);
|
procedure MapX11Window(AWinID: LongWord);
|
||||||
{$IFDEF QtUseAccurateFrame}
|
{$IFDEF QtUseAccurateFrame}
|
||||||
function GetX11SupportedAtoms(AWinID: LongWord; AList: TStrings): boolean;
|
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 GetX11RectForAtom(AWinID: LongWord; const AAtomName: string; out ARect: TRect): boolean;
|
||||||
function GetX11WindowPos(AWinID: LongWord; out ALeft, ATop: integer): boolean;
|
function GetX11WindowPos(AWinID: LongWord; out ALeft, ATop: integer): boolean;
|
||||||
{check if wm supports request for frame extents}
|
{check if wm supports request for frame extents}
|
||||||
function AskX11_NET_REQUEST_FRAME_EXTENTS(AWinID: LongWord; out AMargins: TRect): boolean;
|
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}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
@ -1942,12 +1942,12 @@ begin
|
|||||||
QApplication_syncX();
|
QApplication_syncX();
|
||||||
end;
|
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
|
begin
|
||||||
AId := QWidget_winID(ATempWidget);
|
AId := QWidget_winID(ATempWidget);
|
||||||
I := 0;
|
I := 0;
|
||||||
ATicks := GetTickCount;
|
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
|
begin
|
||||||
QApplication_syncX();
|
QApplication_syncX();
|
||||||
QCoreApplication_processEvents;
|
QCoreApplication_processEvents;
|
||||||
|
@ -7363,9 +7363,10 @@ begin
|
|||||||
R := QtWidgetSet.WSFrameMargins;
|
R := QtWidgetSet.WSFrameMargins;
|
||||||
if (R.Left = 0) and (R.Top = 0) and (R.Bottom = 0) and (R.Right = 0) then
|
if (R.Left = 0) and (R.Top = 0) and (R.Bottom = 0) and (R.Right = 0) then
|
||||||
begin
|
begin
|
||||||
GetWindowFrameSize(QWidget_winID(Widget), R.Left, R.Top, R.Right, R.Bottom);
|
GetX11RectForAtom(QWidget_winID(Widget),'_NET_FRAME_EXTENTS', R);
|
||||||
QtWidgetSet.WSFrameMargins := R;
|
QtWidgetSet.WSFrameMargins := R;
|
||||||
FrameMargins := R;
|
FrameMargins := R;
|
||||||
|
DebugLn('WARNING: TQtMainWindow.EventFilter('+dbgsName(LCLObject)+') setting widgetset frame margins to '+dbgs(R)+' from form activation !');
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
if QX11Info_isCompositingManagerRunning then
|
if QX11Info_isCompositingManagerRunning then
|
||||||
|
@ -375,76 +375,6 @@ begin
|
|||||||
Result := (AXWinAttr.map_installed > 0) and (AXWinAttr.map_state = 2);
|
Result := (AXWinAttr.map_installed > 0) and (AXWinAttr.map_state = 2);
|
||||||
end;
|
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
|
var
|
||||||
InternalExtentsAtom: TAtom = 0; {find extents atom}
|
InternalExtentsAtom: TAtom = 0; {find extents atom}
|
||||||
InternalExtentsCounter: Integer = 0; {counter for bad wm, eg for blackbox}
|
InternalExtentsCounter: Integer = 0; {counter for bad wm, eg for blackbox}
|
||||||
@ -517,7 +447,7 @@ begin
|
|||||||
if XIfEvent(d, @ReturnEvent,
|
if XIfEvent(d, @ReturnEvent,
|
||||||
@propNotifyFrameExtents, TXPointer(@AWinID)) = Success then
|
@propNotifyFrameExtents, TXPointer(@AWinID)) = Success then
|
||||||
begin
|
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
|
if not Result and (InternalExtentsCounter = -BadImplementation) then
|
||||||
begin
|
begin
|
||||||
DebugLn('QtLCL WARNING: "'+GetWindowManager+'" wm bad implementation of _NET_REQUEST_FRAME_EXTENTS.');
|
DebugLn('QtLCL WARNING: "'+GetWindowManager+'" wm bad implementation of _NET_REQUEST_FRAME_EXTENTS.');
|
||||||
|
Loading…
Reference in New Issue
Block a user