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.
This commit is contained in:
Mateo Kuruk Miccino 2020-03-12 20:12:34 -03:00
parent 9a5d15a2dc
commit f387b9b4f4
14 changed files with 157 additions and 65 deletions

View file

@ -31,7 +31,7 @@ matrix:
- name: Linux editor (debug, GCC 9, with Mono) - name: Linux editor (debug, GCC 9, with Mono)
stage: build 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 os: linux
compiler: gcc-9 compiler: gcc-9
addons: addons:
@ -47,7 +47,7 @@ matrix:
- name: Linux export template (release, Clang 7) - name: Linux export template (release, Clang 7)
stage: build 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 os: linux
compiler: clang compiler: clang
addons: addons:
@ -109,7 +109,7 @@ matrix:
- name: Linux export template (release_debug, GCC 7, without 3D support) - name: Linux export template (release_debug, GCC 7, without 3D support)
stage: build 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 os: linux
compiler: gcc compiler: gcc
addons: addons:
@ -165,7 +165,7 @@ script:
scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS && scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS &&
if [ "$TEST_PROJECT" = "yes" ]; then if [ "$TEST_PROJECT" = "yes" ]; then
git clone --depth 1 "https://github.com/godotengine/godot-tests.git"; 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; 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.x11.opt.tools.64"; godot-tests/tests/project_export/test_project.sh "bin/godot_server.linuxbsd.opt.tools.64";
fi fi
fi fi

View file

@ -215,7 +215,7 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
search_box->set_clear_button_enabled(true); search_box->set_clear_button_enabled(true);
[[fallthrough]]; [[fallthrough]];
}; }
case NOTIFICATION_VISIBILITY_CHANGED: { case NOTIFICATION_VISIBILITY_CHANGED: {
search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons"));
} break; } break;

View file

@ -143,7 +143,7 @@ private:
install_status_rect->set_texture(new_icon); install_status_rect->set_texture(new_icon);
} }
set_size(Size2(500, 0) * EDSCALE); set_size(Size2i(500, 0) * EDSCALE);
} }
String _test_path() { String _test_path() {
@ -788,7 +788,7 @@ public:
_test_path(); _test_path();
} }
popup_centered(Size2(500, 0) * EDSCALE); popup_centered(Size2i(500, 0) * EDSCALE);
} }
ProjectDialog() { ProjectDialog() {

View file

@ -905,7 +905,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#else #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"; 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()->print("%s", error_msg.ascii().get_data());
OS::get_singleton()->alert(error_msg); DisplayServer::get_singleton()->alert(error_msg);
goto error; goto error;
#endif #endif

View file

@ -75,7 +75,7 @@ if True: # env['builtin_assimp']:
if(env['platform'] == 'windows'): if(env['platform'] == 'windows'):
env_assimp.Append(CPPDEFINES=['PLATFORM_WINDOWS']) env_assimp.Append(CPPDEFINES=['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'])
env_assimp.Append(CPPDEFINES=[('PLATFORM', 'LINUX')]) env_assimp.Append(CPPDEFINES=[('PLATFORM', 'LINUX')])
elif(env['platform'] == 'osx'): elif(env['platform'] == 'osx'):

View file

@ -45,11 +45,11 @@ def copy_file(src_dir, dst_dir, name):
def is_desktop(platform): 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): 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): def module_supports_tools_on(platform):

View file

@ -3,7 +3,7 @@ def can_build(env, platform):
def configure(env): 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') raise RuntimeError('This module does not currently support building for this platform')
env.use_ptrcall = True env.use_ptrcall = True

View file

@ -33,7 +33,7 @@ namespace GodotTools.Utils
{ {
public const string Windows = "windows"; public const string Windows = "windows";
public const string OSX = "osx"; public const string OSX = "osx";
public const string X11 = "x11"; public const string X11 = "linuxbsd";
public const string Server = "server"; public const string Server = "server";
public const string UWP = "uwp"; public const string UWP = "uwp";
public const string Haiku = "haiku"; public const string Haiku = "haiku";

View file

@ -270,12 +270,12 @@ if env["platform"] == 'uwp':
webm_cpu_x86 = True webm_cpu_x86 = True
else: else:
import platform 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_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')) is_android_x86 = (env["platform"] == 'android' and env["android_arch"].startswith('x86'))
if is_android_x86: if is_android_x86:
cpu_bits = '32' if env["android_arch"] == 'x86' else '64' 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') 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: if webm_cpu_x86:
@ -330,7 +330,7 @@ if webm_cpu_x86:
if webm_cpu_arm: if webm_cpu_arm:
if env["platform"] == 'iphone': if env["platform"] == 'iphone':
env_libvpx["ASFLAGS"] = '-arch armv7' 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' env_libvpx["ASFLAGS"] = '-mfpu=neon'
elif env["platform"] == 'uwp': elif env["platform"] == 'uwp':
env_libvpx["AS"] = 'armasm' env_libvpx["AS"] = 'armasm'

View file

@ -1079,7 +1079,7 @@ Size2i DisplayServerX11::window_get_real_size(WindowID p_window) const {
XFree(data); XFree(data);
} }
} }
return Size2(w, h); return Size2i(w, h);
} }
bool DisplayServerX11::window_is_maximize_allowed(WindowID p_window) const { 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) { if (!p_enabled) {
// Reset the non-resizable flags if we un-set these before. // 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; XSizeHints *xsh;
xsh = XAllocSizeHints(); xsh = XAllocSizeHints();
if (window_get_flag(WINDOW_FLAG_RESIZE_DISABLED, p_window)) { 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; xsh->max_height = size.y;
} else { } else {
xsh->flags = 0L; xsh->flags = 0L;
if (wd.min_size != Size2()) { if (wd.min_size != Size2i()) {
xsh->flags |= PMinSize; xsh->flags |= PMinSize;
xsh->min_width = wd.min_size.x; xsh->min_width = wd.min_size.x;
xsh->min_height = wd.min_size.y; xsh->min_height = wd.min_size.y;
} }
if (wd.max_size != Size2()) { if (wd.max_size != Size2i()) {
xsh->flags |= PMaxSize; xsh->flags |= PMaxSize;
xsh->max_width = wd.max_size.x; xsh->max_width = wd.max_size.x;
xsh->max_height = wd.max_size.y; 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; XSizeHints *xsh;
xsh = XAllocSizeHints(); xsh = XAllocSizeHints();
if (p_enabled) { if (p_enabled) {
Size2 size = window_get_size(p_window); Size2i size = window_get_size(p_window);
xsh->flags = PMinSize | PMaxSize; xsh->flags = PMinSize | PMaxSize;
xsh->min_width = size.x; 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; xsh->max_height = size.y;
} else { } else {
xsh->flags = 0L; xsh->flags = 0L;
if (wd.min_size != Size2()) { if (wd.min_size != Size2i()) {
xsh->flags |= PMinSize; xsh->flags |= PMinSize;
xsh->min_width = wd.min_size.x; xsh->min_width = wd.min_size.x;
xsh->min_height = wd.min_size.y; xsh->min_height = wd.min_size.y;
} }
if (wd.max_size != Size2()) { if (wd.max_size != Size2i()) {
xsh->flags |= PMaxSize; xsh->flags |= PMaxSize;
xsh->max_width = wd.max_size.x; xsh->max_width = wd.max_size.x;
xsh->max_height = wd.max_size.y; 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<Texture2D> texture = p_cursor;
Ref<AtlasTexture> atlas_texture = p_cursor; Ref<AtlasTexture> atlas_texture = p_cursor;
Ref<Image> image; Ref<Image> image;
Size2 texture_size; Size2i texture_size;
Rect2 atlas_rect; Rect2i atlas_rect;
if (texture.is_valid()) { if (texture.is_valid()) {
image = texture->get_data(); image = texture->get_data();
@ -2221,7 +2221,7 @@ void DisplayServerX11::_window_changed(XEvent *event) {
WindowID window_id = MAIN_WINDOW_ID; 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()) { for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
if (event->xany.window == E->get().x11_window) { if (event->xany.window == E->get().x11_window) {
window_id = E->key(); window_id = E->key();
@ -2230,6 +2230,9 @@ void DisplayServerX11::_window_changed(XEvent *event) {
} }
WindowData &wd = windows[window_id]; WindowData &wd = windows[window_id];
if (wd.x11_window != event->xany.window) { // Check if the correct window
return;
}
if (wd.xic) { if (wd.xic) {
// Not portable. // Not portable.
@ -2314,7 +2317,7 @@ void DisplayServerX11::process_events() {
WindowID window_id = MAIN_WINDOW_ID; 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()) { for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
if (event.xany.window == E->get().x11_window) { if (event.xany.window == E->get().x11_window) {
window_id = E->key(); window_id = E->key();
@ -2995,8 +2998,87 @@ void DisplayServerX11::set_context(Context p_context) {
void DisplayServerX11::set_native_icon(const String &p_filename) { void DisplayServerX11::set_native_icon(const String &p_filename) {
WARN_PRINT("Native icon not supported by this display server."); 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) { 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() { Vector<String> DisplayServerX11::get_rendering_drivers_func() {
@ -3042,38 +3124,9 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
WindowData wd; 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); 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); 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 //associate PID
// make PID known to X11 // make PID known to X11
{ {
const long pid = OS::get_singleton()->get_process_id(); 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++; id = window_id_counter++;
windows[id] = wd; 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]; WindowData &wd = windows[id];
@ -3168,7 +3256,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, u
wd.size.width = xwa.width; wd.size.width = xwa.width;
wd.size.height = xwa.height; 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 //set cursor

View file

@ -119,7 +119,7 @@ class DisplayServerX11 : public DisplayServer {
Size2i min_size; Size2i min_size;
Size2i max_size; Size2i max_size;
Size2i size; Size2i size;
Size2i im_position; Point2i im_position;
bool im_active = false; bool im_active = false;
Callable rect_changed_callback; Callable rect_changed_callback;
Callable event_callback; Callable event_callback;

View file

@ -16,7 +16,7 @@ def get_name():
def get_program_suffix(): def get_program_suffix():
if (sys.platform == "darwin"): if (sys.platform == "darwin"):
return "osx" return "osx"
return "x11" return "linuxbsd"
def can_build(): def can_build():

View file

@ -5062,7 +5062,7 @@ void TextEdit::_update_caches() {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
cache.line_spacing = get_theme_constant("line_spacing") * EDSCALE; cache.line_spacing = get_theme_constant("line_spacing") * EDSCALE;
#else #else
cache.line_spacing = get_constant("line_spacing"); cache.line_spacing = get_theme_constant("line_spacing");
#endif #endif
cache.row_height = cache.font->get_height() + cache.line_spacing; cache.row_height = cache.font->get_height() + cache.line_spacing;
cache.tab_icon = get_theme_icon("tab"); cache.tab_icon = get_theme_icon("tab");

View file

@ -99,7 +99,9 @@ Size2i Window::get_real_size() const {
void Window::set_max_size(const Size2i &p_max_size) { void Window::set_max_size(const Size2i &p_max_size) {
max_size = 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(); _update_window_size();
} }
Size2i Window::get_max_size() const { 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) { void Window::set_min_size(const Size2i &p_min_size) {
min_size = 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(); _update_window_size();
} }
Size2i Window::get_min_size() const { Size2i Window::get_min_size() const {
@ -270,8 +274,8 @@ void Window::_clear_window() {
DisplayServer::get_singleton()->delete_sub_window(window_id); DisplayServer::get_singleton()->delete_sub_window(window_id);
window_id = DisplayServer::INVALID_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); VS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), VS::VIEWPORT_UPDATE_DISABLED);
} }