Skip to content

Commit 4153ef7

Browse files
authored
[X11] Ensure XSync before calling CreateNativeControlCore (#15952)
1 parent 5d2ba6d commit 4153ef7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Avalonia.X11/X11NativeControlHost.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ public X11NativeControlHost(AvaloniaX11Platform platform, X11Window window)
1919

2020
public INativeControlHostDestroyableControlHandle CreateDefaultChild(IPlatformHandle parent)
2121
{
22-
var ch = new DumbWindow(_platform.Info);
23-
XSync(_platform.Display, false);
24-
return ch;
22+
return new DumbWindow(_platform.Info, true);
2523
}
2624

2725
public INativeControlHostControlTopLevelAttachment CreateNewAttachment(Func<IPlatformHandle, IPlatformHandle> create)
2826
{
29-
var holder = new DumbWindow(_platform.Info, Window.Handle.Handle);
27+
var holder = new DumbWindow(_platform.Info, true, Window.Handle.Handle);
3028
Attachment attachment = null;
3129
try
3230
{
@@ -50,7 +48,7 @@ public INativeControlHostControlTopLevelAttachment CreateNewAttachment(IPlatform
5048
if (!IsCompatibleWith(handle))
5149
throw new ArgumentException(handle.HandleDescriptor + " is not compatible with the current window",
5250
nameof(handle));
53-
var attachment = new Attachment(_platform.Display, new DumbWindow(_platform.Info, Window.Handle.Handle),
51+
var attachment = new Attachment(_platform.Display, new DumbWindow(_platform.Info, false, Window.Handle.Handle),
5452
_platform.OrphanedWindow, handle) { AttachedTo = this };
5553
return attachment;
5654
}
@@ -61,7 +59,7 @@ private class DumbWindow : INativeControlHostDestroyableControlHandle
6159
{
6260
private readonly IntPtr _display;
6361

64-
public DumbWindow(X11Info x11, IntPtr? parent = null)
62+
public DumbWindow(X11Info x11, bool sync, IntPtr? parent = null)
6563
{
6664
_display = x11.Display;
6765
/*Handle = XCreateSimpleWindow(x11.Display, XLib.XDefaultRootWindow(_display),
@@ -83,6 +81,8 @@ public DumbWindow(X11Info x11, IntPtr? parent = null)
8381
new UIntPtr((uint)(SetWindowValuemask.BorderPixel | SetWindowValuemask.BitGravity |
8482
SetWindowValuemask.BackPixel |
8583
SetWindowValuemask.WinGravity | SetWindowValuemask.BackingStore)), ref attr);
84+
if(sync)
85+
XSync(x11.Display, false);
8686
}
8787

8888
public IntPtr Handle { get; private set; }

0 commit comments

Comments
 (0)