mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 11:28:17 -04:00
fix crash when xrandr is not used
This commit is contained in:
parent
7aa44fe7e3
commit
b83c81bee4
@ -91,9 +91,15 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
_xwindow = (X11_Window)NULL;
|
_xwindow = (X11_Window)NULL;
|
||||||
_ic = (XIC)NULL;
|
_ic = (XIC)NULL;
|
||||||
_visual_info = NULL;
|
_visual_info = NULL;
|
||||||
|
|
||||||
#ifdef HAVE_XRANDR
|
#ifdef HAVE_XRANDR
|
||||||
_orig_size_id = -1;
|
_orig_size_id = -1;
|
||||||
|
int event, error;
|
||||||
|
_have_xrandr = XRRQueryExtension(_display, &event, &error);
|
||||||
|
#else
|
||||||
|
_have_xrandr = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_awaiting_configure = false;
|
_awaiting_configure = false;
|
||||||
_dga_mouse_enabled = false;
|
_dga_mouse_enabled = false;
|
||||||
_wm_delete_window = x11_pipe->_wm_delete_window;
|
_wm_delete_window = x11_pipe->_wm_delete_window;
|
||||||
@ -480,50 +486,52 @@ set_properties_now(WindowProperties &properties) {
|
|||||||
// Handle fullscreen mode.
|
// Handle fullscreen mode.
|
||||||
if (properties.has_fullscreen()) {
|
if (properties.has_fullscreen()) {
|
||||||
if (properties.get_fullscreen()) {
|
if (properties.get_fullscreen()) {
|
||||||
|
if (_have_xrandr) {
|
||||||
#ifdef HAVE_XRANDR
|
#ifdef HAVE_XRANDR
|
||||||
XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, x11_pipe->get_root());
|
XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, x11_pipe->get_root());
|
||||||
if (_orig_size_id == (SizeID) -1) {
|
if (_orig_size_id == (SizeID) -1) {
|
||||||
_orig_size_id = XRRConfigCurrentConfiguration(conf, &_orig_rotation);
|
_orig_size_id = XRRConfigCurrentConfiguration(conf, &_orig_rotation);
|
||||||
}
|
|
||||||
int num_sizes, reqsizex, reqsizey, new_size_id = -1;
|
|
||||||
if (properties.has_size()) {
|
|
||||||
reqsizex = properties.get_x_size();
|
|
||||||
reqsizey = properties.get_y_size();
|
|
||||||
} else {
|
|
||||||
reqsizex = _properties.get_x_size();
|
|
||||||
reqsizey = _properties.get_y_size();
|
|
||||||
}
|
|
||||||
XRRScreenSize *xrrs;
|
|
||||||
xrrs = XRRSizes(_display, 0, &num_sizes);
|
|
||||||
for (int i = 0; i < num_sizes; ++i) {
|
|
||||||
if (xrrs[i].width == properties.get_x_size() &&
|
|
||||||
xrrs[i].height == properties.get_y_size()) {
|
|
||||||
new_size_id = i;
|
|
||||||
}
|
}
|
||||||
}
|
int num_sizes, reqsizex, reqsizey, new_size_id = -1;
|
||||||
if (new_size_id == -1) {
|
if (properties.has_size()) {
|
||||||
x11display_cat.error()
|
reqsizex = properties.get_x_size();
|
||||||
<< "Videocard has no supported display resolutions at specified res ("
|
reqsizey = properties.get_y_size();
|
||||||
<< reqsizex << " x " << reqsizey <<")\n";
|
|
||||||
_orig_size_id = -1;
|
|
||||||
} else {
|
|
||||||
if (new_size_id != _orig_size_id) {
|
|
||||||
XRRSetScreenConfig(_display, conf, x11_pipe->get_root(), new_size_id, _orig_rotation, CurrentTime);
|
|
||||||
} else {
|
} else {
|
||||||
_orig_size_id = -1;
|
reqsizex = _properties.get_x_size();
|
||||||
|
reqsizey = _properties.get_y_size();
|
||||||
|
}
|
||||||
|
XRRScreenSize *xrrs;
|
||||||
|
xrrs = XRRSizes(_display, 0, &num_sizes);
|
||||||
|
for (int i = 0; i < num_sizes; ++i) {
|
||||||
|
if (xrrs[i].width == properties.get_x_size() &&
|
||||||
|
xrrs[i].height == properties.get_y_size()) {
|
||||||
|
new_size_id = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (new_size_id == -1) {
|
||||||
|
x11display_cat.error()
|
||||||
|
<< "Videocard has no supported display resolutions at specified res ("
|
||||||
|
<< reqsizex << " x " << reqsizey <<")\n";
|
||||||
|
_orig_size_id = -1;
|
||||||
|
} else {
|
||||||
|
if (new_size_id != _orig_size_id) {
|
||||||
|
XRRSetScreenConfig(_display, conf, x11_pipe->get_root(), new_size_id, _orig_rotation, CurrentTime);
|
||||||
|
} else {
|
||||||
|
_orig_size_id = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#else
|
|
||||||
// If we don't have Xrandr support, we fake the fullscreen
|
|
||||||
// support by setting the window size to the desktop size.
|
|
||||||
properties.set_size(x11_pipe->get_display_width(),
|
|
||||||
x11_pipe->get_display_height());
|
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
// If we don't have Xrandr support, we fake the fullscreen
|
||||||
|
// support by setting the window size to the desktop size.
|
||||||
|
properties.set_size(x11_pipe->get_display_width(),
|
||||||
|
x11_pipe->get_display_height());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAVE_XRANDR
|
#ifdef HAVE_XRANDR
|
||||||
// Change the resolution back to what it was.
|
// Change the resolution back to what it was.
|
||||||
// Don't remove the SizeID typecast!
|
// Don't remove the SizeID typecast!
|
||||||
if (_orig_size_id != (SizeID) -1) {
|
if (_have_xrandr && _orig_size_id != (SizeID) -1) {
|
||||||
XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, x11_pipe->get_root());
|
XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, x11_pipe->get_root());
|
||||||
XRRSetScreenConfig(_display, conf, x11_pipe->get_root(), _orig_size_id, _orig_rotation, CurrentTime);
|
XRRSetScreenConfig(_display, conf, x11_pipe->get_root(), _orig_size_id, _orig_rotation, CurrentTime);
|
||||||
_orig_size_id = -1;
|
_orig_size_id = -1;
|
||||||
@ -776,7 +784,7 @@ close_window() {
|
|||||||
#ifdef HAVE_XRANDR
|
#ifdef HAVE_XRANDR
|
||||||
// Change the resolution back to what it was.
|
// Change the resolution back to what it was.
|
||||||
// Don't remove the SizeID typecast!
|
// Don't remove the SizeID typecast!
|
||||||
if (_orig_size_id != (SizeID) -1) {
|
if (_have_xrandr && _orig_size_id != (SizeID) -1) {
|
||||||
X11_Window root;
|
X11_Window root;
|
||||||
if (_pipe != NULL) {
|
if (_pipe != NULL) {
|
||||||
x11GraphicsPipe *x11_pipe;
|
x11GraphicsPipe *x11_pipe;
|
||||||
@ -824,7 +832,7 @@ open_window() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XRANDR
|
#ifdef HAVE_XRANDR
|
||||||
if (_properties.get_fullscreen()) {
|
if (_properties.get_fullscreen() && _have_xrandr) {
|
||||||
XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, x11_pipe->get_root());
|
XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, x11_pipe->get_root());
|
||||||
if (_orig_size_id == (SizeID) -1) {
|
if (_orig_size_id == (SizeID) -1) {
|
||||||
_orig_size_id = XRRConfigCurrentConfiguration(conf, &_orig_rotation);
|
_orig_size_id = XRRConfigCurrentConfiguration(conf, &_orig_rotation);
|
||||||
|
@ -88,6 +88,7 @@ protected:
|
|||||||
XIC _ic;
|
XIC _ic;
|
||||||
XVisualInfo *_visual_info;
|
XVisualInfo *_visual_info;
|
||||||
|
|
||||||
|
bool _have_xrandr;
|
||||||
#ifdef HAVE_XRANDR
|
#ifdef HAVE_XRANDR
|
||||||
Rotation _orig_rotation;
|
Rotation _orig_rotation;
|
||||||
SizeID _orig_size_id;
|
SizeID _orig_size_id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user