From 5ba70158dfc4e0825d2535a1c97646f4a0aa42a1 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Thu, 7 Mar 2024 19:18:08 +0000 Subject: [PATCH] x11-force window size hints when window disabled (#14859) --- src/Avalonia.X11/X11Window.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.X11/X11Window.cs b/src/Avalonia.X11/X11Window.cs index 2609a86a2c..cf1f8c5790 100644 --- a/src/Avalonia.X11/X11Window.cs +++ b/src/Avalonia.X11/X11Window.cs @@ -297,6 +297,12 @@ namespace Avalonia.X11 if (!IsEnabled) { functions &= ~(MotifFunctions.Resize | MotifFunctions.Minimize); + + UpdateSizeHints(null, true); + } + else + { + UpdateSizeHints(null); } var hints = new MotifWmHints @@ -311,14 +317,14 @@ namespace Avalonia.X11 PropertyMode.Replace, ref hints, 5); } - private void UpdateSizeHints(PixelSize? preResize) + private void UpdateSizeHints(PixelSize? preResize, bool forceDisableResize = false) { if (_overrideRedirect) return; var min = _minMaxSize.minSize; var max = _minMaxSize.maxSize; - if (!_canResize) + if (!_canResize || forceDisableResize) { if (preResize.HasValue) { @@ -1293,6 +1299,13 @@ namespace Avalonia.X11 UpdateWMHints(); UpdateMotifHints(); + + if (enable) + { + // Some window managers ignore Motif hints when switching from disabled to enabled on the first update + // so setting it again forces the update + UpdateMotifHints(); + } } private void UpdateWMHints()