Skip to content

[X11] Ensure XSync before calling CreateNativeControlCore #15952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Avalonia.X11/X11NativeControlHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ public X11NativeControlHost(AvaloniaX11Platform platform, X11Window window)

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<IPlatformHandle, IPlatformHandle> create)
{
var holder = new DumbWindow(_platform.Info, Window.Handle.Handle);
var holder = new DumbWindow(_platform.Info, true, Window.Handle.Handle);
Attachment attachment = null;
try
{
Expand All @@ -50,7 +48,7 @@ public INativeControlHostControlTopLevelAttachment CreateNewAttachment(IPlatform
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;
}
Expand All @@ -61,7 +59,7 @@ private class DumbWindow : INativeControlHostDestroyableControlHandle
{
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),
Expand All @@ -83,6 +81,8 @@ public DumbWindow(X11Info x11, IntPtr? parent = null)
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; }
Expand Down
Loading