summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateo Kuruk Miccino <mateomiccino@gmail.com>2020-03-12 20:12:34 -0300
committerMateo Kuruk Miccino <mateomiccino@gmail.com>2020-03-26 15:49:54 +0100
commitf387b9b4f4ef3ae6eba5199b4089ef591f2d7ba2 (patch)
treee9551e973d3b534c769279bba2ad58c7d991d2bf
parent9a5d15a2dcb08aa9f3732a0e8e41f2e81c2be365 (diff)
Multiple changes to DisplayServerX11
- Travis: Change x11 to linuxbsd - SCons: Change x11 plataform to linuxbsd - Plugins: Remove ; to avoid fallthrough warning - DisplayServerX11: Implement set_icon - DisplayServerX11: Fix X11 bug when a window was erased from windows map, all the changes from that erased windows are sending to the main window - DisplayServerX11: Reorder create_window commands - DisplayServerX11: Change every Size2 to Size2i and Rect2 to Rect2i where it belongs + More X11 fixes which have been integrated directly back into reduz's original commits while rebasing the branch.
-rw-r--r--.travis.yml10
-rw-r--r--editor/plugins/script_editor_plugin.cpp2
-rw-r--r--editor/project_manager.cpp4
-rw-r--r--main/main.cpp2
-rw-r--r--modules/assimp/SCsub2
-rw-r--r--modules/mono/build_scripts/mono_configure.py4
-rw-r--r--modules/mono/config.py2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs2
-rw-r--r--modules/webm/libvpx/SCsub6
-rw-r--r--platform/linuxbsd/display_server_x11.cpp172
-rw-r--r--platform/linuxbsd/display_server_x11.h2
-rw-r--r--platform/server/detect.py2
-rw-r--r--scene/gui/text_edit.cpp2
-rw-r--r--scene/main/window.cpp10
14 files changed, 157 insertions, 65 deletions
diff --git a/.travis.yml b/.travis.yml
index eeeedef063..f6c40382dd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,7 +31,7 @@ matrix:
- name: Linux editor (debug, GCC 9, with Mono)
stage: build
- env: PLATFORM=x11 TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc-9 MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" EXTRA_ARGS="module_mono_enabled=yes mono_glue=no warnings=extra werror=yes"
+ env: PLATFORM=linuxbsd TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc-9 MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" EXTRA_ARGS="module_mono_enabled=yes mono_glue=no warnings=extra werror=yes"
os: linux
compiler: gcc-9
addons:
@@ -47,7 +47,7 @@ matrix:
- name: Linux export template (release, Clang 7)
stage: build
- env: PLATFORM=x11 TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes"
+ env: PLATFORM=linuxbsd TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes"
os: linux
compiler: clang
addons:
@@ -109,7 +109,7 @@ matrix:
- name: Linux export template (release_debug, GCC 7, without 3D support)
stage: build
- env: PLATFORM=x11 TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-gcc-7 EXTRA_ARGS="disable_3d=yes"
+ env: PLATFORM=linuxbsd TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-gcc-7 EXTRA_ARGS="disable_3d=yes"
os: linux
compiler: gcc
addons:
@@ -165,7 +165,7 @@ script:
scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS &&
if [ "$TEST_PROJECT" = "yes" ]; then
git clone --depth 1 "https://github.com/godotengine/godot-tests.git";
- sed -i "s:custom_template/release=\"\":custom_template/release=\"$(readlink -e bin/godot_server.x11.opt.tools.64)\":" godot-tests/tests/project_export/export_presets.cfg;
- godot-tests/tests/project_export/test_project.sh "bin/godot_server.x11.opt.tools.64";
+ sed -i "s:custom_template/release=\"\":custom_template/release=\"$(readlink -e bin/godot_server.linuxbsd.opt.tools.64)\":" godot-tests/tests/project_export/export_presets.cfg;
+ godot-tests/tests/project_export/test_project.sh "bin/godot_server.linuxbsd.opt.tools.64";
fi
fi
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 67b3745e0d..0e867f7b16 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -215,7 +215,7 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
search_box->set_clear_button_enabled(true);
[[fallthrough]];
- };
+ }
case NOTIFICATION_VISIBILITY_CHANGED: {
search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons"));
} break;
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 168decd788..b4e4ed73f2 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -143,7 +143,7 @@ private:
install_status_rect->set_texture(new_icon);
}
- set_size(Size2(500, 0) * EDSCALE);
+ set_size(Size2i(500, 0) * EDSCALE);
}
String _test_path() {
@@ -788,7 +788,7 @@ public:
_test_path();
}
- popup_centered(Size2(500, 0) * EDSCALE);
+ popup_centered(Size2i(500, 0) * EDSCALE);
}
ProjectDialog() {
diff --git a/main/main.cpp b/main/main.cpp
index 2ce3001829..c9fde81f7a 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -905,7 +905,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#else
const String error_msg = "Error: Couldn't load project data at path \"" + project_path + "\". Is the .pck file missing?\nIf you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).\n";
OS::get_singleton()->print("%s", error_msg.ascii().get_data());
- OS::get_singleton()->alert(error_msg);
+ DisplayServer::get_singleton()->alert(error_msg);
goto error;
#endif
diff --git a/modules/assimp/SCsub b/modules/assimp/SCsub
index 90cdd7f5fc..cef2396dfb 100644
--- a/modules/assimp/SCsub
+++ b/modules/assimp/SCsub
@@ -75,7 +75,7 @@ if True: # env['builtin_assimp']:
if(env['platform'] == 'windows'):
env_assimp.Append(CPPDEFINES=['PLATFORM_WINDOWS'])
env_assimp.Append(CPPDEFINES=[('PLATFORM', 'WINDOWS')])
- elif(env['platform'] == 'x11'):
+ elif(env['platform'] == 'linuxbsd'):
env_assimp.Append(CPPDEFINES=['PLATFORM_LINUX'])
env_assimp.Append(CPPDEFINES=[('PLATFORM', 'LINUX')])
elif(env['platform'] == 'osx'):
diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py
index 9a6198f13a..4e101583ef 100644
--- a/modules/mono/build_scripts/mono_configure.py
+++ b/modules/mono/build_scripts/mono_configure.py
@@ -45,11 +45,11 @@ def copy_file(src_dir, dst_dir, name):
def is_desktop(platform):
- return platform in ['windows', 'osx', 'x11', 'server', 'uwp', 'haiku']
+ return platform in ['windows', 'osx', 'linuxbsd', 'server', 'uwp', 'haiku']
def is_unix_like(platform):
- return platform in ['osx', 'x11', 'server', 'android', 'haiku']
+ return platform in ['osx', 'linuxbsd', 'server', 'android', 'haiku']
def module_supports_tools_on(platform):
diff --git a/modules/mono/config.py b/modules/mono/config.py
index a5d3059ecc..3ee1618366 100644
--- a/modules/mono/config.py
+++ b/modules/mono/config.py
@@ -3,7 +3,7 @@ def can_build(env, platform):
def configure(env):
- if env['platform'] not in ['windows', 'osx', 'x11', 'server', 'android', 'haiku', 'javascript']:
+ if env['platform'] not in ['windows', 'osx', 'linuxbsd', 'server', 'android', 'haiku', 'javascript']:
raise RuntimeError('This module does not currently support building for this platform')
env.use_ptrcall = True
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
index 279e67b3eb..11a4109d97 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
@@ -33,7 +33,7 @@ namespace GodotTools.Utils
{
public const string Windows = "windows";
public const string OSX = "osx";
- public const string X11 = "x11";
+ public const string X11 = "linuxbsd";
public const string Server = "server";
public const string UWP = "uwp";
public const string Haiku = "haiku";
diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub
index 14fa6c1268..6aed8a16f5 100644
--- a/modules/webm/libvpx/SCsub
+++ b/modules/webm/libvpx/SCsub
@@ -270,12 +270,12 @@ if env["platform"] == 'uwp':
webm_cpu_x86 = True
else:
import platform
- is_x11_or_server_arm = ((env["platform"] == 'x11' or env["platform"] == 'server') and (platform.machine().startswith('arm') or platform.machine().startswith('aarch')))
+ is_x11_or_server_arm = ((env["platform"] == 'linuxbsd' or env["platform"] == 'server') and (platform.machine().startswith('arm') or platform.machine().startswith('aarch')))
is_ios_x86 = (env["platform"] == 'iphone' and ("arch" in env and env["arch"].startswith('x86')))
is_android_x86 = (env["platform"] == 'android' and env["android_arch"].startswith('x86'))
if is_android_x86:
cpu_bits = '32' if env["android_arch"] == 'x86' else '64'
- webm_cpu_x86 = not is_x11_or_server_arm and (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'x11' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86 or is_ios_x86)
+ webm_cpu_x86 = not is_x11_or_server_arm and (cpu_bits == '32' or cpu_bits == '64') and (env["platform"] == 'windows' or env["platform"] == 'linuxbsd' or env["platform"] == 'osx' or env["platform"] == 'haiku' or is_android_x86 or is_ios_x86)
webm_cpu_arm = is_x11_or_server_arm or (not is_ios_x86 and env["platform"] == 'iphone') or (not is_android_x86 and env["platform"] == 'android')
if webm_cpu_x86:
@@ -330,7 +330,7 @@ if webm_cpu_x86:
if webm_cpu_arm:
if env["platform"] == 'iphone':
env_libvpx["ASFLAGS"] = '-arch armv7'
- elif env["platform"] == 'android' and env["android_arch"] == 'armv7' or env["platform"] == 'x11' or env["platform"] == 'server':
+ elif env["platform"] == 'android' and env["android_arch"] == 'armv7' or env["platform"] == 'linuxbsd' or env["platform"] == 'server':
env_libvpx["ASFLAGS"] = '-mfpu=neon'
elif env["platform"] == 'uwp':
env_libvpx["AS"] = 'armasm'
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp
index ffe6af41e2..d847270e64 100644
--- a/platform/linuxbsd/display_server_x11.cpp
+++ b/platform/linuxbsd/display_server_x11.cpp
@@ -1079,7 +1079,7 @@ Size2i DisplayServerX11::window_get_real_size(WindowID p_window) const {
XFree(data);
}
}
- return Size2(w, h);
+ return Size2i(w, h);
}
bool DisplayServerX11::window_is_maximize_allowed(WindowID p_window) const {
@@ -1214,7 +1214,7 @@ void DisplayServerX11::_set_wm_fullscreen(WindowID p_window, bool p_enabled) {
if (!p_enabled) {
// Reset the non-resizable flags if we un-set these before.
- Size2 size = window_get_size(p_window);
+ Size2i size = window_get_size(p_window);
XSizeHints *xsh;
xsh = XAllocSizeHints();
if (window_get_flag(WINDOW_FLAG_RESIZE_DISABLED, p_window)) {
@@ -1225,12 +1225,12 @@ void DisplayServerX11::_set_wm_fullscreen(WindowID p_window, bool p_enabled) {
xsh->max_height = size.y;
} else {
xsh->flags = 0L;
- if (wd.min_size != Size2()) {
+ if (wd.min_size != Size2i()) {
xsh->flags |= PMinSize;
xsh->min_width = wd.min_size.x;
xsh->min_height = wd.min_size.y;
}
- if (wd.max_size != Size2()) {
+ if (wd.max_size != Size2i()) {
xsh->flags |= PMaxSize;
xsh->max_width = wd.max_size.x;
xsh->max_height = wd.max_size.y;
@@ -1471,7 +1471,7 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
XSizeHints *xsh;
xsh = XAllocSizeHints();
if (p_enabled) {
- Size2 size = window_get_size(p_window);
+ Size2i size = window_get_size(p_window);
xsh->flags = PMinSize | PMaxSize;
xsh->min_width = size.x;
@@ -1480,12 +1480,12 @@ void DisplayServerX11::window_set_flag(WindowFlags p_flag, bool p_enabled, Windo
xsh->max_height = size.y;
} else {
xsh->flags = 0L;
- if (wd.min_size != Size2()) {
+ if (wd.min_size != Size2i()) {
xsh->flags |= PMinSize;
xsh->min_width = wd.min_size.x;
xsh->min_height = wd.min_size.y;
}
- if (wd.max_size != Size2()) {
+ if (wd.max_size != Size2i()) {
xsh->flags |= PMaxSize;
xsh->max_width = wd.max_size.x;
xsh->max_height = wd.max_size.y;
@@ -1749,8 +1749,8 @@ void DisplayServerX11::cursor_set_custom_image(const RES &p_cursor, CursorShape
Ref<Texture2D> texture = p_cursor;
Ref<AtlasTexture> atlas_texture = p_cursor;
Ref<Image> image;
- Size2 texture_size;
- Rect2 atlas_rect;
+ Size2i texture_size;
+ Rect2i atlas_rect;
if (texture.is_valid()) {
image = texture->get_data();
@@ -2221,7 +2221,7 @@ void DisplayServerX11::_window_changed(XEvent *event) {
WindowID window_id = MAIN_WINDOW_ID;
- //assign the event to the relevant window
+ // Assign the event to the relevant window
for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
if (event->xany.window == E->get().x11_window) {
window_id = E->key();
@@ -2230,6 +2230,9 @@ void DisplayServerX11::_window_changed(XEvent *event) {
}
WindowData &wd = windows[window_id];
+ if (wd.x11_window != event->xany.window) { // Check if the correct window
+ return;
+ }
if (wd.xic) {
// Not portable.
@@ -2314,7 +2317,7 @@ void DisplayServerX11::process_events() {
WindowID window_id = MAIN_WINDOW_ID;
- //assign the event to the relevant window
+ // Assign the event to the relevant window
for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
if (event.xany.window == E->get().x11_window) {
window_id = E->key();
@@ -2995,8 +2998,87 @@ void DisplayServerX11::set_context(Context p_context) {
void DisplayServerX11::set_native_icon(const String &p_filename) {
WARN_PRINT("Native icon not supported by this display server.");
}
+
+bool g_set_icon_error = false;
+int set_icon_errorhandler(Display *dpy, XErrorEvent *ev) {
+ g_set_icon_error = true;
+ return 0;
+}
+
void DisplayServerX11::set_icon(const Ref<Image> &p_icon) {
- WARN_PRINT("Icon not supported by this display server.");
+ _THREAD_SAFE_METHOD_
+
+ WindowData &wd = windows[MAIN_WINDOW_ID];
+
+ int (*oldHandler)(Display *, XErrorEvent *) = XSetErrorHandler(&set_icon_errorhandler);
+
+ Atom net_wm_icon = XInternAtom(x11_display, "_NET_WM_ICON", False);
+
+ if (p_icon.is_valid()) {
+ Ref<Image> img = p_icon->duplicate();
+ img->convert(Image::FORMAT_RGBA8);
+
+ while (true) {
+ int w = img->get_width();
+ int h = img->get_height();
+
+ if (g_set_icon_error) {
+ g_set_icon_error = false;
+
+ WARN_PRINT("Icon too large, attempting to resize icon.");
+
+ int new_width, new_height;
+ if (w > h) {
+ new_width = w / 2;
+ new_height = h * new_width / w;
+ } else {
+ new_height = h / 2;
+ new_width = w * new_height / h;
+ }
+
+ w = new_width;
+ h = new_height;
+
+ if (!w || !h) {
+ WARN_PRINT("Unable to set icon.");
+ break;
+ }
+
+ img->resize(w, h, Image::INTERPOLATE_CUBIC);
+ }
+
+ // We're using long to have wordsize (32Bit build -> 32 Bits, 64 Bit build -> 64 Bits
+ Vector<long> pd;
+
+ pd.resize(2 + w * h);
+
+ pd.write[0] = w;
+ pd.write[1] = h;
+
+ const uint8_t *r = img->get_data().ptr();
+
+ long *wr = &pd.write[2];
+ uint8_t const *pr = r;
+
+ for (int i = 0; i < w * h; i++) {
+ long v = 0;
+ // A R G B
+ v |= pr[3] << 24 | pr[0] << 16 | pr[1] << 8 | pr[2];
+ *wr++ = v;
+ pr += 4;
+ }
+
+ XChangeProperty(x11_display, wd.x11_window, net_wm_icon, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)pd.ptr(), pd.size());
+
+ if (!g_set_icon_error)
+ break;
+ }
+ } else {
+ XDeleteProperty(x11_display, wd.x11_window, net_wm_icon);
+ }
+
+ XFlush(x11_display);
+ XSetErrorHandler(oldHandler);
}
Vector<String> DisplayServerX11::get_rendering_drivers_func() {
@@ -3042,38 +3124,9 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
WindowData wd;
wd.x11_window = XCreateWindow(x11_display, RootWindow(x11_display, visualInfo->screen), p_rect.position.x, p_rect.position.y, p_rect.size.width, p_rect.size.height, 0, visualInfo->depth, InputOutput, visualInfo->visual, valuemask, &windowAttributes);
- if (windows.size() > 0) {
- //this is a sub window, don't let the window manager put it wherever it wants
-
- XSizeHints my_hints = { 0 };
-
- my_hints.flags = PPosition | PSize; /* I want to specify position and size */
- my_hints.x = p_rect.position.x; /* The origin and size coords I want */
- my_hints.y = p_rect.position.y;
- my_hints.width = p_rect.size.width;
- my_hints.height = p_rect.size.height;
-
- XSetNormalHints(x11_display, wd.x11_window, &my_hints);
- //its still not working :(
- }
- //set_class_hint(x11_display, wd.x11_window);
XMapWindow(x11_display, wd.x11_window);
- XFlush(x11_display);
-
- XSync(x11_display, False);
- //XSetErrorHandler(oldHandler);
-
- XFree(visualInfo);
-
-#if defined(VULKAN_ENABLED)
- if (context_vulkan) {
- Error err = context_vulkan->window_create(window_id_counter, wd.x11_window, x11_display, p_rect.size.width, p_rect.size.height);
- ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan window");
- }
-#endif
//associate PID
-
// make PID known to X11
{
const long pid = OS::get_singleton()->get_process_id();
@@ -3152,6 +3205,41 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
id = window_id_counter++;
windows[id] = wd;
+
+ if (id != MAIN_WINDOW_ID) {
+ //this is a sub window, don't let the window manager put it wherever it wants
+ for (int i = 0; i < WINDOW_FLAG_MAX; i++) {
+ if (p_flags & (1 << i)) {
+ window_set_flag(WindowFlags(i), true, id);
+ }
+ }
+
+ XSizeHints my_hints = XSizeHints();
+
+ my_hints.flags = PPosition | PSize; /* I want to specify position and size */
+ my_hints.x = p_rect.position.x; /* The origin and size coords I want */
+ my_hints.y = p_rect.position.y;
+ my_hints.width = p_rect.size.width;
+ my_hints.height = p_rect.size.height;
+
+ XSetNormalHints(x11_display, wd.x11_window, &my_hints);
+ XMoveWindow(x11_display, wd.x11_window, p_rect.position.x, p_rect.position.y);
+ }
+
+#if defined(VULKAN_ENABLED)
+ if (context_vulkan) {
+ Error err = context_vulkan->window_create(id, wd.x11_window, x11_display, p_rect.size.width, p_rect.size.height);
+ ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create a Vulkan window");
+ }
+#endif
+
+ //set_class_hint(x11_display, wd.x11_window);
+ XFlush(x11_display);
+
+ XSync(x11_display, False);
+ //XSetErrorHandler(oldHandler);
+
+ XFree(visualInfo);
}
WindowData &wd = windows[id];
@@ -3168,7 +3256,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
wd.size.width = xwa.width;
wd.size.height = xwa.height;
- //print_line("created at rect: " + p_rect + " but at rect " + Rect2i(xwa.x, xwa.y, xwa.width, xwa.height));
+ print_line("created at rect: " + p_rect + " but at rect " + Rect2i(xwa.x, xwa.y, xwa.width, xwa.height));
}
//set cursor
diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h
index 5747ac93ba..10067671e7 100644
--- a/platform/linuxbsd/display_server_x11.h
+++ b/platform/linuxbsd/display_server_x11.h
@@ -119,7 +119,7 @@ class DisplayServerX11 : public DisplayServer {
Size2i min_size;
Size2i max_size;
Size2i size;
- Size2i im_position;
+ Point2i im_position;
bool im_active = false;
Callable rect_changed_callback;
Callable event_callback;
diff --git a/platform/server/detect.py b/platform/server/detect.py
index db9ba8d036..4ea4bddddd 100644
--- a/platform/server/detect.py
+++ b/platform/server/detect.py
@@ -16,7 +16,7 @@ def get_name():
def get_program_suffix():
if (sys.platform == "darwin"):
return "osx"
- return "x11"
+ return "linuxbsd"
def can_build():
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 5bc920b04e..49e89f6c6d 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -5062,7 +5062,7 @@ void TextEdit::_update_caches() {
#ifdef TOOLS_ENABLED
cache.line_spacing = get_theme_constant("line_spacing") * EDSCALE;
#else
- cache.line_spacing = get_constant("line_spacing");
+ cache.line_spacing = get_theme_constant("line_spacing");
#endif
cache.row_height = cache.font->get_height() + cache.line_spacing;
cache.tab_icon = get_theme_icon("tab");
diff --git a/scene/main/window.cpp b/scene/main/window.cpp
index f8a86b0957..6c2e2f1d31 100644
--- a/scene/main/window.cpp
+++ b/scene/main/window.cpp
@@ -99,7 +99,9 @@ Size2i Window::get_real_size() const {
void Window::set_max_size(const Size2i &p_max_size) {
max_size = p_max_size;
- DisplayServer::get_singleton()->window_set_min_size(max_size, window_id);
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_max_size(max_size, window_id);
+ }
_update_window_size();
}
Size2i Window::get_max_size() const {
@@ -110,7 +112,9 @@ Size2i Window::get_max_size() const {
void Window::set_min_size(const Size2i &p_min_size) {
min_size = p_min_size;
- DisplayServer::get_singleton()->window_set_max_size(max_size, window_id);
+ if (window_id != DisplayServer::INVALID_WINDOW_ID) {
+ DisplayServer::get_singleton()->window_set_min_size(max_size, window_id);
+ }
_update_window_size();
}
Size2i Window::get_min_size() const {
@@ -270,8 +274,8 @@ void Window::_clear_window() {
DisplayServer::get_singleton()->delete_sub_window(window_id);
window_id = DisplayServer::INVALID_WINDOW_ID;
- _update_viewport_size();
+ _update_viewport_size();
VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_DISABLED);
}