diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index d9e18720dc1..648d127f38d 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -744,7 +744,7 @@ int DisplayServerX11::get_screen_count() const { // Using Xinerama Extension int event_base, error_base; - if (XineramaQueryExtension(x11_display, &event_base, &error_base)) { + if (xinerama_ext_ok && XineramaQueryExtension(x11_display, &event_base, &error_base)) { XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count); XFree(xsi); } else { @@ -756,7 +756,7 @@ int DisplayServerX11::get_screen_count() const { int DisplayServerX11::get_primary_screen() const { int event_base, error_base; - if (XineramaQueryExtension(x11_display, &event_base, &error_base)) { + if (xinerama_ext_ok && XineramaQueryExtension(x11_display, &event_base, &error_base)) { return 0; } else { return XDefaultScreen(x11_display); @@ -809,7 +809,7 @@ Rect2i DisplayServerX11::_screen_get_rect(int p_screen) const { // Using Xinerama Extension. int event_base, error_base; - if (XineramaQueryExtension(x11_display, &event_base, &error_base)) { + if (xinerama_ext_ok && XineramaQueryExtension(x11_display, &event_base, &error_base)) { int count; XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count); @@ -1244,7 +1244,7 @@ Ref DisplayServerX11::screen_get_image(int p_screen) const { XImage *image = nullptr; int event_base, error_base; - if (XineramaQueryExtension(x11_display, &event_base, &error_base)) { + if (xinerama_ext_ok && XineramaQueryExtension(x11_display, &event_base, &error_base)) { int xin_count; XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &xin_count); if (p_screen < xin_count) { @@ -1580,6 +1580,7 @@ void DisplayServerX11::window_set_mouse_passthrough(const Vector &p_reg void DisplayServerX11::_update_window_mouse_passthrough(WindowID p_window) { ERR_FAIL_COND(!windows.has(p_window)); + ERR_FAIL_COND(!xshaped_ext_ok); const Vector region_path = windows[p_window].mpath; @@ -5429,13 +5430,11 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode } if (initialize_xinerama(dylibloader_verbose) != 0) { - r_error = ERR_UNAVAILABLE; - ERR_FAIL_MSG("Can't load Xinerama dynamically."); + xinerama_ext_ok = false; } if (initialize_xrandr(dylibloader_verbose) != 0) { - r_error = ERR_UNAVAILABLE; - ERR_FAIL_MSG("Can't load Xrandr dynamically."); + xrandr_ext_ok = false; } if (initialize_xrender(dylibloader_verbose) != 0) { @@ -5505,42 +5504,36 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode return; } - { + if (xshaped_ext_ok) { int version_major = 0; int version_minor = 0; int rc = XShapeQueryVersion(x11_display, &version_major, &version_minor); print_verbose(vformat("Xshape %d.%d detected.", version_major, version_minor)); if (rc != 1 || version_major < 1) { - ERR_PRINT("Unsupported Xshape library version."); - r_error = ERR_UNAVAILABLE; - XCloseDisplay(x11_display); - return; + xshaped_ext_ok = false; + print_verbose("Unsupported Xshape library version."); } } - { + if (xinerama_ext_ok) { int version_major = 0; int version_minor = 0; int rc = XineramaQueryVersion(x11_display, &version_major, &version_minor); print_verbose(vformat("Xinerama %d.%d detected.", version_major, version_minor)); if (rc != 1 || version_major < 1) { - ERR_PRINT("Unsupported Xinerama library version."); - r_error = ERR_UNAVAILABLE; - XCloseDisplay(x11_display); - return; + xinerama_ext_ok = false; + print_verbose("Unsupported Xinerama library version."); } } - { + if (xrandr_ext_ok) { int version_major = 0; int version_minor = 0; int rc = XRRQueryVersion(x11_display, &version_major, &version_minor); print_verbose(vformat("Xrandr %d.%d detected.", version_major, version_minor)); if (rc != 1 || (version_major == 1 && version_minor < 3) || (version_major < 1)) { - ERR_PRINT("Unsupported Xrandr library version."); - r_error = ERR_UNAVAILABLE; - XCloseDisplay(x11_display); - return; + xrandr_ext_ok = false; + print_verbose("Unsupported Xrandr library version."); } } @@ -5606,7 +5599,9 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode if (!xrandr_handle) { fprintf(stderr, "could not load libXrandr.so.2, Error: %s\n", err); } - } else { + } + + if (xrandr_handle) { XRRQueryVersion(x11_display, &xrandr_major, &xrandr_minor); if (((xrandr_major << 8) | xrandr_minor) >= 0x0105) { xrr_get_monitors = (xrr_get_monitors_t)dlsym(xrandr_handle, "XRRGetMonitors"); diff --git a/platform/linuxbsd/x11/display_server_x11.h b/platform/linuxbsd/x11/display_server_x11.h index 180362923ba..f8e38b7c7bb 100644 --- a/platform/linuxbsd/x11/display_server_x11.h +++ b/platform/linuxbsd/x11/display_server_x11.h @@ -322,7 +322,9 @@ class DisplayServerX11 : public DisplayServer { xrr_get_monitors_t xrr_get_monitors = nullptr; xrr_free_monitors_t xrr_free_monitors = nullptr; void *xrandr_handle = nullptr; - Bool xrandr_ext_ok; + bool xrandr_ext_ok = true; + bool xinerama_ext_ok = true; + bool xshaped_ext_ok = true; struct Property { unsigned char *data;