Browse Source

Merge pull request #3453 from AvaloniaUI/fixes/x11-backend-cope-with-0size-window

Fixes/x11 backend cope with 0size window
pull/3465/head
danwalmsley 7 years ago
committed by GitHub
parent
commit
8a3f592083
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Avalonia.X11/X11Framebuffer.cs
  2. 8
      src/Avalonia.X11/X11Window.cs
  3. 2
      src/Shared/PlatformSupport/StandardRuntimePlatform.cs

4
src/Avalonia.X11/X11Framebuffer.cs

@ -14,6 +14,10 @@ namespace Avalonia.X11
public X11Framebuffer(IntPtr display, IntPtr xid, int depth, int width, int height, double factor)
{
// HACK! Please fix renderer, should never ask for 0x0 bitmap.
width = Math.Max(1, width);
height = Math.Max(1, height);
_display = display;
_xid = xid;
_depth = depth;

8
src/Avalonia.X11/X11Window.cs

@ -102,7 +102,7 @@ namespace Avalonia.X11
valueMask |= SetWindowValuemask.ColorMap;
}
int defaultWidth = 300, defaultHeight = 200;
int defaultWidth = 0, defaultHeight = 0;
if (!_popup && Screen != null)
{
@ -117,6 +117,10 @@ namespace Avalonia.X11
}
}
// check if the calculated size is zero then compensate to hardcoded resolution
defaultWidth = Math.Max(defaultWidth, 300);
defaultHeight = Math.Max(defaultHeight, 200);
_handle = XCreateWindow(_x11.Display, _x11.RootWindow, 10, 10, defaultWidth, defaultHeight, 0,
depth,
(int)CreateWindowArgs.InputOutput,
@ -133,7 +137,7 @@ namespace Avalonia.X11
_renderHandle = _handle;
Handle = new PlatformHandle(_handle, "XID");
_realSize = new PixelSize(300, 200);
_realSize = new PixelSize(defaultWidth, defaultHeight);
platform.Windows[_handle] = OnEvent;
XEventMask ignoredMask = XEventMask.SubstructureRedirectMask
| XEventMask.ResizeRedirectMask

2
src/Shared/PlatformSupport/StandardRuntimePlatform.cs

@ -75,7 +75,7 @@ namespace Avalonia.Shared.PlatformSupport
lock (_btlock)
Backtraces.Remove(_backtrace);
#endif
_plat.Free(_address, Size);
_plat?.Free(_address, Size);
GC.RemoveMemoryPressure(Size);
IsDisposed = true;
_address = IntPtr.Zero;

Loading…
Cancel
Save