Skip to content

Commit

Permalink
Additional sanity checks for monitor resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacato committed Jan 20, 2020
1 parent 32df775 commit 7e42523
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Avalonia.X11/X11Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public X11Window(AvaloniaX11Platform platform, IWindowImpl popupParent)
valueMask |= SetWindowValuemask.ColorMap;
}

int defaultWidth = 300, defaultHeight = 200;
int defaultWidth = 0, defaultHeight = 0;

if (!_popup && Screen != null)
{
Expand All @@ -117,6 +117,10 @@ public X11Window(AvaloniaX11Platform platform, IWindowImpl popupParent)
}
}

// 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,
Expand All @@ -133,7 +137,7 @@ public X11Window(AvaloniaX11Platform platform, IWindowImpl popupParent)
_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
Expand Down

0 comments on commit 7e42523

Please sign in to comment.