From 93de351d2ff0bfdc52dfadc82135b1858d8001f6 Mon Sep 17 00:00:00 2001 From: zeljan1 Date: Wed, 12 Feb 2025 17:32:00 +0100 Subject: [PATCH] Gtk3: implemented TGtk3Widgetset.SetWindowPos() --- lcl/interfaces/gtk3/gtk3winapi.inc | 63 ++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/lcl/interfaces/gtk3/gtk3winapi.inc b/lcl/interfaces/gtk3/gtk3winapi.inc index 3a8e68b6ad..c9e9162805 100644 --- a/lcl/interfaces/gtk3/gtk3winapi.inc +++ b/lcl/interfaces/gtk3/gtk3winapi.inc @@ -4351,11 +4351,66 @@ end; function TGtk3WidgetSet.SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND; X, Y, cx, cy: Integer; uFlags: UINT): Boolean; +var + DisableUpdates: boolean; + AGtkWidget: TGtk3Widget absolute hWnd; + Alloc: TGtkAllocation; begin - Result := False; - {$IFDEF GTK3DEBUGNOTIMPLEMENTED} - DebugLn('WARNING: TGtk3WidgetSet.SetWindowPos not implemented Handle=',dbgHex(hWnd),' X=',dbgs(X),' Y=',dbgs(Y)); - {$ENDIF} + Result := IsValidHandle(hWnd); + if not Result then + exit; + + DisableUpdates := (SWP_NOREDRAW and uFlags) <> 0; + if DisableUpdates then + begin + if Gtk3IsGdkWindow(AGtkWidget.Widget^.window) then + AGtkWidget.Widget^.window^.freeze_updates; + end; + try + if ((SWP_NOMOVE and uFlags) = 0) and ((SWP_NOSIZE and uFlags) = 0) then + begin + AGtkWidget.SetBounds(X, Y, CX, CY); + end else + begin + if (SWP_NOMOVE and uFlags) = 0 then + begin + Alloc.X := X; + Alloc.Y := Y; + Alloc.width := AGtkWidget.Widget^.get_allocated_width; + Alloc.height := AGtkWidget.Widget^.get_allocated_height; + AGtkWidget.SetBounds(X, Y, Alloc.Width, Alloc.Height); + end; + + if (SWP_NOSIZE and uFlags) = 0 then + AGtkWidget.SetBounds(X, Y, CX, CY); + end; + + if (SWP_SHOWWINDOW and uFlags) <> 0 then + AGtkWidget.ShowAll; + + if (SWP_HIDEWINDOW and uFlags) <> 0 then + AGtkWidget.Hide; + + if (SWP_NOZORDER and uFlags) = 0 then + begin + case hWndInsertAfter of + HWND_TOP: + begin + aGtkWidget.raiseWidget; + if (SWP_NOACTIVATE and uFlags) = 0 then + aGtkWidget.Activate; + end; + HWND_BOTTOM: AGtkWidget.lowerWidget; + {TODO: HWND_TOPMOST ,HWND_NOTOPMOST} + end; + end; + finally + if DisableUpdates then + begin + if Gtk3IsGdkWindow(AGtkWidget.Widget^.window) then + AGtkWidget.Widget^.window^.thaw_updates; + end; + end; end; function TGtk3WidgetSet.SetWindowRgn(hWnd: HWND; hRgn: HRGN; bRedraw: Boolean