Skip to content

Commit fa9e33e

Browse files
committed
Revert "Fix popups position on X11 (#14551)"
This reverts commit 06f88f6.
1 parent 3b96190 commit fa9e33e

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/Avalonia.X11/X11Window.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ internal unsafe partial class X11Window : IWindowImpl, IPopupImpl, IXI2Client
5353
private PixelSize _realSize;
5454
private bool _cleaningUp;
5555
private IntPtr _handle;
56-
private IntPtr _parentHandle;
5756
private IntPtr _xic;
5857
private IntPtr _renderHandle;
5958
private IntPtr _xSyncCounter;
@@ -85,7 +84,6 @@ public X11Window(AvaloniaX11Platform platform, IWindowImpl? popupParent, bool ov
8584
_mouse = new MouseDevice();
8685
_touch = new TouchDevice();
8786
_keyboard = platform.KeyboardDevice;
88-
_parentHandle = popupParent != null ? ((X11Window)popupParent)._handle : _x11.RootWindow;
8987

9088
var glfeature = AvaloniaLocator.Current.GetService<IPlatformGraphics>();
9189
XSetWindowAttributes attr = new XSetWindowAttributes();
@@ -123,7 +121,7 @@ public X11Window(AvaloniaX11Platform platform, IWindowImpl? popupParent, bool ov
123121
{
124122
visual = visualInfo.Value.visual;
125123
depth = (int)visualInfo.Value.depth;
126-
attr.colormap = XCreateColormap(_x11.Display, _parentHandle, visualInfo.Value.visual, 0);
124+
attr.colormap = XCreateColormap(_x11.Display, _x11.RootWindow, visualInfo.Value.visual, 0);
127125
valueMask |= SetWindowValuemask.ColorMap;
128126
}
129127

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

149-
_handle = XCreateWindow(_x11.Display, _parentHandle, 10, 10, defaultWidth, defaultHeight, 0,
147+
var parentHandle = popupParent != null ? ((X11Window)popupParent)._handle : _x11.RootWindow;
148+
149+
_handle = XCreateWindow(_x11.Display, parentHandle, 10, 10, defaultWidth, defaultHeight, 0,
150150
depth,
151151
(int)CreateWindowArgs.InputOutput,
152152
visual,
@@ -517,7 +517,7 @@ private void OnEvent(ref XEvent ev)
517517
_configurePoint = new PixelPoint(ev.ConfigureEvent.x, ev.ConfigureEvent.y);
518518
else
519519
{
520-
XTranslateCoordinates(_x11.Display, _handle, _parentHandle,
520+
XTranslateCoordinates(_x11.Display, _handle, _x11.RootWindow,
521521
0, 0,
522522
out var tx, out var ty, out _);
523523
_configurePoint = new PixelPoint(tx, ty);
@@ -1100,12 +1100,10 @@ public PixelPoint Position
11001100
UpdateSizeHints(null);
11011101
}
11021102

1103-
XTranslateCoordinates(_x11.Display, _parentHandle, _x11.RootWindow, 0, 0, out var wx, out var wy, out _);
1104-
11051103
var changes = new XWindowChanges
11061104
{
1107-
x = value.X - wx,
1108-
y = (int)value.Y - wy
1105+
x = value.X,
1106+
y = (int)value.Y
11091107
};
11101108

11111109
XConfigureWindow(_x11.Display, _handle, ChangeWindowFlags.CWX | ChangeWindowFlags.CWY,
@@ -1168,7 +1166,7 @@ private void SendNetWMMessage(IntPtr message_type, IntPtr l0,
11681166
}
11691167
};
11701168
xev.ClientMessageEvent.ptr4 = l4 ?? IntPtr.Zero;
1171-
XSendEvent(_x11.Display, _parentHandle, false,
1169+
XSendEvent(_x11.Display, _x11.RootWindow, false,
11721170
new IntPtr((int)(EventMask.SubstructureRedirectMask | EventMask.SubstructureNotifyMask)), ref xev);
11731171

11741172
}

0 commit comments

Comments
 (0)