fix crash when xrandr is not used

This commit is contained in:
rdb 2012-07-01 15:20:24 +00:00
parent 7aa44fe7e3
commit b83c81bee4
2 changed files with 91 additions and 82 deletions

View File

@ -91,9 +91,15 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
_xwindow = (X11_Window)NULL;
_ic = (XIC)NULL;
_visual_info = NULL;
#ifdef HAVE_XRANDR
_orig_size_id = -1;
int event, error;
_have_xrandr = XRRQueryExtension(_display, &event, &error);
#else
_have_xrandr = false;
#endif
_awaiting_configure = false;
_dga_mouse_enabled = false;
_wm_delete_window = x11_pipe->_wm_delete_window;
@ -480,6 +486,7 @@ set_properties_now(WindowProperties &properties) {
// Handle fullscreen mode.
if (properties.has_fullscreen()) {
if (properties.get_fullscreen()) {
if (_have_xrandr) {
#ifdef HAVE_XRANDR
XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, x11_pipe->get_root());
if (_orig_size_id == (SizeID) -1) {
@ -513,17 +520,18 @@ set_properties_now(WindowProperties &properties) {
_orig_size_id = -1;
}
}
#else
#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());
#endif
}
} else {
#ifdef HAVE_XRANDR
// Change the resolution back to what it was.
// 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());
XRRSetScreenConfig(_display, conf, x11_pipe->get_root(), _orig_size_id, _orig_rotation, CurrentTime);
_orig_size_id = -1;
@ -776,7 +784,7 @@ close_window() {
#ifdef HAVE_XRANDR
// Change the resolution back to what it was.
// Don't remove the SizeID typecast!
if (_orig_size_id != (SizeID) -1) {
if (_have_xrandr && _orig_size_id != (SizeID) -1) {
X11_Window root;
if (_pipe != NULL) {
x11GraphicsPipe *x11_pipe;
@ -824,7 +832,7 @@ open_window() {
}
#ifdef HAVE_XRANDR
if (_properties.get_fullscreen()) {
if (_properties.get_fullscreen() && _have_xrandr) {
XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, x11_pipe->get_root());
if (_orig_size_id == (SizeID) -1) {
_orig_size_id = XRRConfigCurrentConfiguration(conf, &_orig_rotation);

View File

@ -88,6 +88,7 @@ protected:
XIC _ic;
XVisualInfo *_visual_info;
bool _have_xrandr;
#ifdef HAVE_XRANDR
Rotation _orig_rotation;
SizeID _orig_size_id;