Skip to content
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

Fixes/revert x11 popup changes #14573

Merged
merged 2 commits into from
Feb 10, 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
16 changes: 6 additions & 10 deletions src/Avalonia.X11/X11Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ internal unsafe partial class X11Window : IWindowImpl, IPopupImpl, IXI2Client
private PixelSize _realSize;
private bool _cleaningUp;
private IntPtr _handle;
private IntPtr _parentHandle;
private IntPtr _xic;
private IntPtr _renderHandle;
private IntPtr _xSyncCounter;
Expand Down Expand Up @@ -85,7 +84,6 @@ public X11Window(AvaloniaX11Platform platform, IWindowImpl? popupParent, bool ov
_mouse = new MouseDevice();
_touch = new TouchDevice();
_keyboard = platform.KeyboardDevice;
_parentHandle = popupParent != null ? ((X11Window)popupParent)._handle : _x11.RootWindow;

var glfeature = AvaloniaLocator.Current.GetService<IPlatformGraphics>();
XSetWindowAttributes attr = new XSetWindowAttributes();
Expand Down Expand Up @@ -123,7 +121,7 @@ public X11Window(AvaloniaX11Platform platform, IWindowImpl? popupParent, bool ov
{
visual = visualInfo.Value.visual;
depth = (int)visualInfo.Value.depth;
attr.colormap = XCreateColormap(_x11.Display, _parentHandle, visualInfo.Value.visual, 0);
attr.colormap = XCreateColormap(_x11.Display, _x11.RootWindow, visualInfo.Value.visual, 0);
valueMask |= SetWindowValuemask.ColorMap;
}

Expand All @@ -146,7 +144,7 @@ public X11Window(AvaloniaX11Platform platform, IWindowImpl? popupParent, bool ov
defaultWidth = Math.Max(defaultWidth, 300);
defaultHeight = Math.Max(defaultHeight, 200);

_handle = XCreateWindow(_x11.Display, _parentHandle, 10, 10, defaultWidth, defaultHeight, 0,
_handle = XCreateWindow(_x11.Display, _x11.RootWindow, 10, 10, defaultWidth, defaultHeight, 0,
depth,
(int)CreateWindowArgs.InputOutput,
visual,
Expand Down Expand Up @@ -517,7 +515,7 @@ private void OnEvent(ref XEvent ev)
_configurePoint = new PixelPoint(ev.ConfigureEvent.x, ev.ConfigureEvent.y);
else
{
XTranslateCoordinates(_x11.Display, _handle, _parentHandle,
XTranslateCoordinates(_x11.Display, _handle, _x11.RootWindow,
0, 0,
out var tx, out var ty, out _);
_configurePoint = new PixelPoint(tx, ty);
Expand Down Expand Up @@ -1100,12 +1098,10 @@ public PixelPoint Position
UpdateSizeHints(null);
}

XTranslateCoordinates(_x11.Display, _parentHandle, _x11.RootWindow, 0, 0, out var wx, out var wy, out _);

var changes = new XWindowChanges
{
x = value.X - wx,
y = (int)value.Y - wy
x = value.X,
y = (int)value.Y
};

XConfigureWindow(_x11.Display, _handle, ChangeWindowFlags.CWX | ChangeWindowFlags.CWY,
Expand Down Expand Up @@ -1168,7 +1164,7 @@ private void SendNetWMMessage(IntPtr message_type, IntPtr l0,
}
};
xev.ClientMessageEvent.ptr4 = l4 ?? IntPtr.Zero;
XSendEvent(_x11.Display, _parentHandle, false,
XSendEvent(_x11.Display, _x11.RootWindow, false,
new IntPtr((int)(EventMask.SubstructureRedirectMask | EventMask.SubstructureNotifyMask)), ref xev);

}
Expand Down
Loading