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