diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-27 09:34:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-27 09:34:25 +0200 |
commit | e89fc52ec62c247c4d88e3592972426173bb24a7 (patch) | |
tree | 4b5100c7f039228c57e027866faa9e017d579ae3 /platform/linuxbsd | |
parent | a19d7d8f8d1c82e8dcd2bff4cb2f7fb3a9c9862e (diff) | |
parent | 372e24265ad2c557721a7f8f50a67e9c96358b02 (diff) |
Merge pull request #58272 from bruvzg/x11_backup_screen_info
Diffstat (limited to 'platform/linuxbsd')
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 7da30ac363..acc7d1bc30 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -670,17 +670,17 @@ void DisplayServerX11::_clipboard_transfer_ownership(Atom p_source, Window x11_w int DisplayServerX11::get_screen_count() const { _THREAD_SAFE_METHOD_ + int count = 0; // Using Xinerama Extension int event_base, error_base; - const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); - if (!ext_okay) { - return 0; + if (XineramaQueryExtension(x11_display, &event_base, &error_base)) { + XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count); + XFree(xsi); + } else { + count = XScreenCount(x11_display); } - int count; - XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count); - XFree(xsi); return count; } @@ -712,6 +712,19 @@ Rect2i DisplayServerX11::_screen_get_rect(int p_screen) const { if (xsi) { XFree(xsi); } + } else { + int count = XScreenCount(x11_display); + if (p_screen < count) { + Window root = XRootWindow(x11_display, p_screen); + XWindowAttributes xwa; + XGetWindowAttributes(x11_display, root, &xwa); + rect.position.x = xwa.x; + rect.position.y = xwa.y; + rect.size.width = xwa.width; + rect.size.height = xwa.height; + } else { + ERR_PRINT("Invalid screen index: " + itos(p_screen) + "(count: " + itos(count) + ")."); + } } return rect; |