Merge pull request #91933 from bruvzg/x11_scr_fb
[X11] Fallback to root window size, when Xinerama extension is available, but return zero screens.
This commit is contained in:
commit
b802c7274f
1 changed files with 40 additions and 27 deletions
|
@ -1007,7 +1007,8 @@ int DisplayServerX11::get_screen_count() const {
|
|||
if (xinerama_ext_ok && XineramaQueryExtension(x11_display, &event_base, &error_base)) {
|
||||
XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count);
|
||||
XFree(xsi);
|
||||
} else {
|
||||
}
|
||||
if (count == 0) {
|
||||
count = XScreenCount(x11_display);
|
||||
}
|
||||
|
||||
|
@ -1068,25 +1069,29 @@ Rect2i DisplayServerX11::_screen_get_rect(int p_screen) const {
|
|||
ERR_FAIL_COND_V(p_screen < 0, rect);
|
||||
|
||||
// Using Xinerama Extension.
|
||||
bool found = false;
|
||||
int event_base, error_base;
|
||||
if (xinerama_ext_ok && XineramaQueryExtension(x11_display, &event_base, &error_base)) {
|
||||
int count;
|
||||
XineramaScreenInfo *xsi = XineramaQueryScreens(x11_display, &count);
|
||||
|
||||
if (xsi) {
|
||||
if (count > 0) {
|
||||
// Check if screen is valid.
|
||||
if (p_screen < count) {
|
||||
rect.position.x = xsi[p_screen].x_org;
|
||||
rect.position.y = xsi[p_screen].y_org;
|
||||
rect.size.width = xsi[p_screen].width;
|
||||
rect.size.height = xsi[p_screen].height;
|
||||
found = true;
|
||||
} else {
|
||||
ERR_PRINT("Invalid screen index: " + itos(p_screen) + "(count: " + itos(count) + ").");
|
||||
ERR_PRINT(vformat("Invalid screen index: %d (count: %d).", p_screen, count));
|
||||
}
|
||||
}
|
||||
|
||||
if (xsi) {
|
||||
XFree(xsi);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
int count = XScreenCount(x11_display);
|
||||
if (p_screen < count) {
|
||||
Window root = XRootWindow(x11_display, p_screen);
|
||||
|
@ -1097,7 +1102,7 @@ Rect2i DisplayServerX11::_screen_get_rect(int p_screen) const {
|
|||
rect.size.width = xwa.width;
|
||||
rect.size.height = xwa.height;
|
||||
} else {
|
||||
ERR_PRINT("Invalid screen index: " + itos(p_screen) + "(count: " + itos(count) + ").");
|
||||
ERR_PRINT(vformat("Invalid screen index: %d (count: %d).", p_screen, count));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1503,10 +1508,13 @@ Ref<Image> DisplayServerX11::screen_get_image(int p_screen) const {
|
|||
|
||||
XImage *image = nullptr;
|
||||
|
||||
bool found = false;
|
||||
int 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 (xsi) {
|
||||
if (xin_count > 0) {
|
||||
if (p_screen < xin_count) {
|
||||
int x_count = XScreenCount(x11_display);
|
||||
for (int i = 0; i < x_count; i++) {
|
||||
|
@ -1514,14 +1522,19 @@ Ref<Image> DisplayServerX11::screen_get_image(int p_screen) const {
|
|||
XWindowAttributes root_attrs;
|
||||
XGetWindowAttributes(x11_display, root, &root_attrs);
|
||||
if ((xsi[p_screen].x_org >= root_attrs.x) && (xsi[p_screen].x_org <= root_attrs.x + root_attrs.width) && (xsi[p_screen].y_org >= root_attrs.y) && (xsi[p_screen].y_org <= root_attrs.y + root_attrs.height)) {
|
||||
found = true;
|
||||
image = XGetImage(x11_display, root, xsi[p_screen].x_org, xsi[p_screen].y_org, xsi[p_screen].width, xsi[p_screen].height, AllPlanes, ZPixmap);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ERR_FAIL_V_MSG(Ref<Image>(), "Invalid screen index: " + itos(p_screen) + "(count: " + itos(xin_count) + ").");
|
||||
ERR_PRINT(vformat("Invalid screen index: %d (count: %d).", p_screen, xin_count));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
XFree(xsi);
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
int x_count = XScreenCount(x11_display);
|
||||
if (p_screen < x_count) {
|
||||
Window root = XRootWindow(x11_display, p_screen);
|
||||
|
@ -1531,7 +1544,7 @@ Ref<Image> DisplayServerX11::screen_get_image(int p_screen) const {
|
|||
|
||||
image = XGetImage(x11_display, root, root_attrs.x, root_attrs.y, root_attrs.width, root_attrs.height, AllPlanes, ZPixmap);
|
||||
} else {
|
||||
ERR_FAIL_V_MSG(Ref<Image>(), "Invalid screen index: " + itos(p_screen) + "(count: " + itos(x_count) + ").");
|
||||
ERR_PRINT(vformat("Invalid screen index: %d (count: %d).", p_screen, x_count));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue