Prevent invalid values when resizing window (X11)

This commit is contained in:
Ev1lbl0w 2021-03-01 12:19:09 +00:00
parent 7e2e96c587
commit be4e34b495
No known key found for this signature in database
GPG key ID: B383693E3746E58A

View file

@ -1421,15 +1421,19 @@ void OS_X11::set_window_size(const Size2 p_size) {
int old_w = xwa.width;
int old_h = xwa.height;
Size2 size = p_size;
size.x = MAX(1, size.x);
size.y = MAX(1, size.y);
// If window resizable is disabled we need to update the attributes first
XSizeHints *xsh;
xsh = XAllocSizeHints();
if (!is_window_resizable()) {
xsh->flags = PMinSize | PMaxSize;
xsh->min_width = p_size.x;
xsh->max_width = p_size.x;
xsh->min_height = p_size.y;
xsh->max_height = p_size.y;
xsh->min_width = size.x;
xsh->max_width = size.x;
xsh->min_height = size.y;
xsh->max_height = size.y;
} else {
xsh->flags = 0L;
if (min_size != Size2()) {
@ -1447,11 +1451,11 @@ void OS_X11::set_window_size(const Size2 p_size) {
XFree(xsh);
// Resize the window
XResizeWindow(x11_display, x11_window, p_size.x, p_size.y);
XResizeWindow(x11_display, x11_window, size.x, size.y);
// Update our videomode width and height
current_videomode.width = p_size.x;
current_videomode.height = p_size.y;
current_videomode.width = size.x;
current_videomode.height = size.y;
for (int timeout = 0; timeout < 50; ++timeout) {
XSync(x11_display, False);