From 8077d8dae05746e2e50034ccdda9c08656018360 Mon Sep 17 00:00:00 2001 From: zeljan1 Date: Mon, 3 Feb 2025 16:56:46 +0100 Subject: [PATCH] Gtk3: fixed GetWindowRect() so it return proper values on x11 and wayland. --- lcl/interfaces/gtk3/gtk3winapi.inc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/gtk3/gtk3winapi.inc b/lcl/interfaces/gtk3/gtk3winapi.inc index 3a62fbfcc1..76cadc9d30 100644 --- a/lcl/interfaces/gtk3/gtk3winapi.inc +++ b/lcl/interfaces/gtk3/gtk3winapi.inc @@ -2952,6 +2952,7 @@ var AWindow: PGtkWindow; x, y, aWidth, aHeight: gint; Allocation: TGtkAllocation; + AGdkWindow: PGdkWindow; begin Result := 0; if IsValidHandle(Handle) then @@ -2961,18 +2962,34 @@ begin AWindow := PGtkWindow(TGtk3Widget(Handle).Widget); if not TGtk3Window(Handle).WidgetMapped then AWindow := nil; + + if AWindow <> nil then + AGdkWindow := AWindow^.get_window + else + AGdkWindow := nil; + end else AWindow := nil; if AWindow <> nil then begin - AWindow^.get_position(@x, @y); - AWindow^.get_size(@aWidth, @aHeight); + if Assigned(AGdkWindow) then + begin + AGdkWindow^.get_origin(@x, @y); + AGdkWindow^.get_frame_extents(@Allocation); + AWidth := Allocation.Width; + AHeight := Allocation.Height; + end else + begin + AWindow^.get_position(@x, @y); + AWindow^.get_size(@aWidth, @aHeight); + end; ARect := Bounds(x, Y, AWidth, AHeight); Result := 1; end else begin TGtk3Widget(Handle).Widget^.get_allocation(@Allocation); ARect := Bounds(Allocation.x, Allocation.y, Allocation.width, Allocation.height); + Result := -1; end; end; end;