diff --git a/.travis.yml b/.travis.yml index 80191423c16a..56f5ef6b38ad 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: @@ -150,7 +150,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 5c9e0737c2bc..5805240adb04 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -216,7 +216,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 af178ad31e81..91d488dd0e09 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -143,7 +143,7 @@ class ProjectDialog : public ConfirmationDialog { 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 @@ class ProjectDialog : public ConfirmationDialog { _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 5a544386879c..0c548177d60c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -909,7 +909,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/main/main_builders.py b/main/main_builders.py index c48aaaa57254..49d2b134b0ae 100644 --- a/main/main_builders.py +++ b/main/main_builders.py @@ -63,68 +63,5 @@ def make_app_icon(target, source, env): g.write("};\n") g.write("#endif") - -def make_default_controller_mappings(target, source, env): - dst = target[0] - g = open(dst, "w") - - g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#include \"core/typedefs.h\"\n") - g.write("#include \"main/default_controller_mappings.h\"\n") - - # ensure mappings have a consistent order - platform_mappings = OrderedDict() - for src_path in source: - with open(src_path, "r") as f: - # read mapping file and skip header - mapping_file_lines = f.readlines()[2:] - - current_platform = None - for line in mapping_file_lines: - if not line: - continue - line = line.strip() - if len(line) == 0: - continue - if line[0] == "#": - current_platform = line[1:].strip() - if current_platform not in platform_mappings: - platform_mappings[current_platform] = {} - elif current_platform: - line_parts = line.split(",") - guid = line_parts[0] - if guid in platform_mappings[current_platform]: - g.write("// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(src_path, current_platform, platform_mappings[current_platform][guid])) - valid_mapping = True - for input_map in line_parts[2:]: - if "+" in input_map or "-" in input_map or "~" in input_map: - g.write("// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(src_path, current_platform, line)) - valid_mapping = False - break - if valid_mapping: - platform_mappings[current_platform][guid] = line - - platform_variables = { - "Linux": "#if X11_ENABLED", - "Windows": "#ifdef WINDOWS_ENABLED", - "Mac OS X": "#ifdef OSX_ENABLED", - "Android": "#if defined(__ANDROID__)", - "iOS": "#ifdef IPHONE_ENABLED", - "Javascript": "#ifdef JAVASCRIPT_ENABLED", - "UWP": "#ifdef UWP_ENABLED", - } - - g.write("const char* DefaultControllerMappings::mappings[] = {\n") - for platform, mappings in platform_mappings.items(): - variable = platform_variables[platform] - g.write("{}\n".format(variable)) - for mapping in mappings.values(): - g.write("\t\"{}\",\n".format(mapping)) - g.write("#endif\n") - - g.write("\tNULL\n};\n") - g.close() - - if __name__ == '__main__': subprocess_main(globals()) diff --git a/modules/assimp/SCsub b/modules/assimp/SCsub index 5e66b50de391..489d483d103b 100644 --- a/modules/assimp/SCsub +++ b/modules/assimp/SCsub @@ -79,7 +79,7 @@ env_assimp.Append(CPPDEFINES=['ASSIMP_BUILD_NO_MMD_IMPORTER']) 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 033c467da907..1742bf528e03 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 70cb464c7ac4..1d1e89a9ec71 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 279e67b3eb59..11a4109d97f5 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs @@ -33,7 +33,7 @@ public static class Platforms { 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 14fa6c126873..6aed8a16f55f 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/detect.py b/platform/linuxbsd/detect.py index 7d4d270830f2..34f36266ac57 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -347,9 +347,9 @@ def configure(env): print("Warning: Creating template binaries enabled for PCK embedding is currently only supported with GNU ld") else: if float(gnu_ld_version.group(1)) >= 2.30: - env.Append(LINKFLAGS=['-T', 'platform/linuxbsd/pck_embed.ld']) + env.Append(LINKFLAGS=['-T', 'platform/linuxbsd/pck_embed.ld']) else: - env.Append(LINKFLAGS=['-T', 'platform/linuxbsd/pck_embed.legacy.ld']) + env.Append(LINKFLAGS=['-T', 'platform/linuxbsd/pck_embed.legacy.ld']) ## Cross-compilation diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 452e22f94999..ed4c456cd3d7 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -534,7 +534,10 @@ Point2i DisplayServerX11::screen_get_position(int p_screen) const { return position; } Size2i DisplayServerX11::screen_get_size(int p_screen) const { + return screen_get_usable_rect(p_screen).size; +} +Rect2i DisplayServerX11::screen_get_usable_rect(int p_screen) const { _THREAD_SAFE_METHOD_ if (p_screen == SCREEN_OF_MAIN_WINDOW) { @@ -544,16 +547,17 @@ Size2i DisplayServerX11::screen_get_size(int p_screen) const { // Using Xinerama Extension int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); - if (!ext_okay) return Size2i(0, 0); + if (!ext_okay) return Rect2i(0, 0, 0, 0); int count; XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count); - if (p_screen >= count) return Size2i(0, 0); + if (p_screen >= count) return Rect2i(0, 0, 0, 0); - Size2i size = Point2i(xsi[p_screen].width, xsi[p_screen].height); + Rect2i rect = Rect2i(xsi[p_screen].x_org, xsi[p_screen].y_org, xsi[p_screen].width, xsi[p_screen].height); XFree(xsi); - return size; + return rect; } + int DisplayServerX11::screen_get_dpi(int p_screen) const { _THREAD_SAFE_METHOD_ @@ -623,12 +627,7 @@ DisplayServer::WindowID DisplayServerX11::create_sub_window(WindowMode p_mode, u _THREAD_SAFE_METHOD_ - WindowID id = _create_window(p_mode, p_rect); - for (int i = 0; i < WINDOW_FLAG_MAX; i++) { - if (p_flags & (1 << i)) { - window_set_flag(WindowFlags(i), true, id); - } - } + WindowID id = _create_window(p_mode, p_flags, p_rect); return id; } @@ -678,13 +677,13 @@ void DisplayServerX11::window_set_title(const String &p_title, WindowID p_window XChangeProperty(x11_display, wd.x11_window, _net_wm_name, utf8_string, 8, PropModeReplace, (unsigned char *)p_title.utf8().get_data(), p_title.utf8().length()); } -void DisplayServerX11::window_set_resize_callback(const Callable &p_callable, WindowID p_window) { +void DisplayServerX11::window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window) { _THREAD_SAFE_METHOD_ ERR_FAIL_COND(!windows.has(p_window)); WindowData &wd = windows[p_window]; - wd.resize_callback = p_callable; + wd.rect_changed_callback = p_callable; } void DisplayServerX11::window_set_window_event_callback(const Callable &p_callable, WindowID p_window) { @@ -1024,7 +1023,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 { @@ -1159,7 +1158,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)) { @@ -1170,12 +1169,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; @@ -1416,7 +1415,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; @@ -1425,12 +1424,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; @@ -1694,8 +1693,8 @@ void DisplayServerX11::cursor_set_custom_image(const RES &p_cursor, CursorShape Ref texture = p_cursor; Ref atlas_texture = p_cursor; Ref image; - Size2 texture_size; - Rect2 atlas_rect; + Size2i texture_size; + Rect2i atlas_rect; if (texture.is_valid()) { image = texture->get_data(); @@ -2148,7 +2147,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::Element *E = windows.front(); E; E = E->next()) { if (event->xany.window == E->get().x11_window) { window_id = E->key(); @@ -2157,6 +2156,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. @@ -2176,12 +2178,12 @@ void DisplayServerX11::_window_changed(XEvent *event) { } #endif - if (!wd.resize_callback.is_null()) { - Variant size = wd.size; - Variant *sizep = &size; + if (!wd.rect_changed_callback.is_null()) { + Variant rect = Rect2i(wd.im_position, wd.size); + Variant *rectp = ▭ Variant ret; Callable::CallError ce; - wd.resize_callback.call((const Variant **)&sizep, 1, ret, ce); + wd.rect_changed_callback.call((const Variant **)&rectp, 1, ret, ce); } } @@ -2241,7 +2243,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::Element *E = windows.front(); E; E = E->next()) { if (event.xany.window == E->get().x11_window) { window_id = E->key(); @@ -2922,8 +2924,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 &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 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 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 DisplayServerX11::get_rendering_drivers_func() { @@ -2944,7 +3025,7 @@ DisplayServer *DisplayServerX11::create_func(const String &p_rendering_driver, W return memnew(DisplayServerX11(p_rendering_driver, p_mode, p_flags, p_resolution, r_error)); } -DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, const Rect2i &p_rect) { +DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect) { //Create window @@ -2969,38 +3050,9 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, c 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(); @@ -3079,6 +3131,41 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, c 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]; @@ -3095,7 +3182,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, c 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 @@ -3333,7 +3420,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode } #endif - WindowID main_window = _create_window(p_mode, Rect2i(Point2(), p_resolution)); + WindowID main_window = _create_window(p_mode, 0, Rect2i(Point2(), p_resolution)); for (int i = 0; i < WINDOW_FLAG_MAX; i++) { if (p_flags & (1 << i)) { window_set_flag(WindowFlags(i), true, main_window); diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index 118416bc57a5..be96d4cec01f 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -89,9 +89,9 @@ class DisplayServerX11 : public DisplayServer { Size2i min_size; Size2i max_size; Size2i size; - Size2i im_position; + Point2i im_position; bool im_active = false; - Callable resize_callback; + Callable rect_changed_callback; Callable event_callback; Callable input_event_callback; Callable input_text_callback; @@ -112,7 +112,7 @@ class DisplayServerX11 : public DisplayServer { Map windows; WindowID window_id_counter = MAIN_WINDOW_ID; - WindowID _create_window(WindowMode p_mode, const Rect2i &p_rect); + WindowID _create_window(WindowMode p_mode, uint32_t p_flags, const Rect2i &p_rect); String internal_clipboard; Window xdnd_source_window; @@ -229,6 +229,7 @@ class DisplayServerX11 : public DisplayServer { virtual int get_screen_count() const; virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const; virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const; + virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const; virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const; virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const; @@ -238,7 +239,7 @@ class DisplayServerX11 : public DisplayServer { virtual void delete_sub_window(WindowID p_id); virtual void window_set_title(const String &p_title, WindowID p_window = MAIN_WINDOW_ID); - virtual void window_set_resize_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); + virtual void window_set_rect_changed_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); virtual void window_set_window_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); virtual void window_set_input_event_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); virtual void window_set_input_text_callback(const Callable &p_callable, WindowID p_window = MAIN_WINDOW_ID); diff --git a/platform/server/detect.py b/platform/server/detect.py index ef94dc436cd7..1a24286ef7c2 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 3154ba250e6b..584dd875241f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -5055,7 +5055,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 4d29cece4b3a..007ed9426e14 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -67,7 +67,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 { @@ -78,7 +80,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 { @@ -237,8 +241,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); } @@ -954,7 +958,7 @@ void Window::popup_centered(const Size2 &p_minsize) { } Rect2 popup_rect; - if (p_minsize == Size2()) { + if (p_minsize.width <= UNIT_EPSILON || p_minsize.height <= UNIT_EPSILON) { popup_rect.size = _get_contents_minimum_size(); } else { popup_rect.size = p_minsize;