From 4153ef720befc635d0ed4ebc0bea0c251060f2df Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sat, 8 Jun 2024 09:28:18 +0300 Subject: [PATCH] [X11] Ensure XSync before calling CreateNativeControlCore (#15952) --- src/Avalonia.X11/X11NativeControlHost.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.X11/X11NativeControlHost.cs b/src/Avalonia.X11/X11NativeControlHost.cs index e8710580eb..09254a032f 100644 --- a/src/Avalonia.X11/X11NativeControlHost.cs +++ b/src/Avalonia.X11/X11NativeControlHost.cs @@ -19,14 +19,12 @@ namespace Avalonia.X11 public INativeControlHostDestroyableControlHandle CreateDefaultChild(IPlatformHandle parent) { - var ch = new DumbWindow(_platform.Info); - XSync(_platform.Display, false); - return ch; + return new DumbWindow(_platform.Info, true); } public INativeControlHostControlTopLevelAttachment CreateNewAttachment(Func create) { - var holder = new DumbWindow(_platform.Info, Window.Handle.Handle); + var holder = new DumbWindow(_platform.Info, true, Window.Handle.Handle); Attachment attachment = null; try { @@ -50,7 +48,7 @@ namespace Avalonia.X11 if (!IsCompatibleWith(handle)) throw new ArgumentException(handle.HandleDescriptor + " is not compatible with the current window", nameof(handle)); - var attachment = new Attachment(_platform.Display, new DumbWindow(_platform.Info, Window.Handle.Handle), + var attachment = new Attachment(_platform.Display, new DumbWindow(_platform.Info, false, Window.Handle.Handle), _platform.OrphanedWindow, handle) { AttachedTo = this }; return attachment; } @@ -61,7 +59,7 @@ namespace Avalonia.X11 { private readonly IntPtr _display; - public DumbWindow(X11Info x11, IntPtr? parent = null) + public DumbWindow(X11Info x11, bool sync, IntPtr? parent = null) { _display = x11.Display; /*Handle = XCreateSimpleWindow(x11.Display, XLib.XDefaultRootWindow(_display), @@ -83,6 +81,8 @@ namespace Avalonia.X11 new UIntPtr((uint)(SetWindowValuemask.BorderPixel | SetWindowValuemask.BitGravity | SetWindowValuemask.BackPixel | SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr); + if(sync) + XSync(x11.Display, false); } public IntPtr Handle { get; private set; }