Use x11 functions in irr_driver only if x11 device was created

This commit is contained in:
Deve 2017-05-14 00:05:36 +02:00
parent da802d836d
commit 1966d3f072
3 changed files with 57 additions and 44 deletions

View File

@ -20,6 +20,7 @@ namespace irr
/** This device works on Windows Mobile, Pocket PC and Microsoft SmartPhone devices */
EIDT_WINCE,
//! A device native to Linux
EIDT_WAYLAND,
//! A device native to Unix style operating systems.

View File

@ -312,6 +312,8 @@ void IrrDriver::updateConfigIfRelevant()
Log::warn("irr_driver", "Could not retrieve window location\n");
}
#elif defined(__linux__) && !defined(ANDROID)
if (m_device->getType() == EIDT_X11)
{
const video::SExposedVideoData& videoData =
m_device->getVideoDriver()->getExposedVideoData();
Display* display = (Display*)videoData.OpenGLLinux.X11Display;
@ -324,11 +326,13 @@ void IrrDriver::updateConfigIfRelevant()
"Retrieved window location for config : %i %i\n", wx, wy);
if (UserConfigParams::m_window_x != wx || UserConfigParams::m_window_y != wy)
if (UserConfigParams::m_window_x != wx ||
UserConfigParams::m_window_y != wy)
{
UserConfigParams::m_window_x = wx;
UserConfigParams::m_window_y = wy;
}
}
#endif
}
@ -418,6 +422,7 @@ void IrrDriver::initDevice()
UserConfigParams::m_width,
UserConfigParams::m_height);
res = modes->getVideoModeResolution(res, res);
UserConfigParams::m_width = res.Width;
UserConfigParams::m_height = res.Height;
}
@ -711,7 +716,9 @@ void IrrDriver::initDevice()
// Only change video driver settings if we are showing graphics
if (!ProfileWorld::isNoGraphics())
{
#if 0//defined(__linux__) && !defined(ANDROID) && !defined(SERVER_ONLY)
#if defined(__linux__) && !defined(ANDROID) && !defined(SERVER_ONLY)
if (m_device->getType() == EIDT_X11)
{
// Set class hints on Linux, used by Window Managers.
const video::SExposedVideoData& videoData = m_video_driver
->getExposedVideoData();
@ -722,6 +729,7 @@ void IrrDriver::initDevice()
videoData.OpenGLLinux.X11Window,
classhint);
XFree(classhint);
}
#endif
m_device->setWindowCaption(L"SuperTuxKart");
m_device->getVideoDriver()
@ -892,7 +900,10 @@ bool IrrDriver::moveWindow(int x, int y)
return false;
}
#elif defined(__linux__) && !defined(ANDROID)
const video::SExposedVideoData& videoData = m_video_driver->getExposedVideoData();
if (m_device->getType() == EIDT_X11)
{
const video::SExposedVideoData& videoData =
m_video_driver->getExposedVideoData();
Display* display = (Display*)videoData.OpenGLLinux.X11Display;
int screen = DefaultScreen(display);
@ -911,6 +922,7 @@ bool IrrDriver::moveWindow(int x, int y)
// TODO: Actually handle possible failure
XMoveWindow(display, videoData.OpenGLLinux.X11Window, x, y);
}
#endif
#endif
return true;