diff --git a/lib/irrlicht/include/IrrlichtDevice.h b/lib/irrlicht/include/IrrlichtDevice.h index 9d4031e22..e7a51ba95 100644 --- a/lib/irrlicht/include/IrrlichtDevice.h +++ b/lib/irrlicht/include/IrrlichtDevice.h @@ -152,6 +152,10 @@ namespace irr /** \param text: New text of the window caption. */ virtual void setWindowCaption(const wchar_t* text) = 0; + //! Sets the class of the window. + /** \param text: New text of the window class. */ + virtual void setWindowClass(const char* text) = 0; + //! Returns if the window is active. /** If the window is inactive, nothing needs to be drawn. So if you don't want to draw anything diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h index 86d3ce1fe..de2998ae9 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h @@ -35,6 +35,7 @@ namespace irr virtual void yield(); virtual void sleep(u32 timeMs, bool pauseTimer=false); virtual void setWindowCaption(const wchar_t* text); + virtual void setWindowClass(const char* text) {} virtual bool present(video::IImage* surface, void* windowId, core::rect* srcClip); virtual bool isWindowActive() const; virtual bool isWindowFocused() const; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceConsole.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceConsole.h index 8052182b7..3c711c728 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceConsole.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceConsole.h @@ -59,6 +59,9 @@ namespace irr //! sets the caption of the window virtual void setWindowCaption(const wchar_t* text); + //! sets the class of the window + virtual void setWindowClass(const char* text) {} + //! returns if window is active. if not, nothing need to be drawn virtual bool isWindowActive() const; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceFB.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceFB.h index 07a9aca10..d75a25ad5 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceFB.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceFB.h @@ -45,6 +45,9 @@ namespace irr //! sets the caption of the window virtual void setWindowCaption(const wchar_t* text); + //! sets the class of the window + virtual void setWindowClass(const char* text) {} + //! returns if window is active. if not, nothing need to be drawn virtual bool isWindowActive() const; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp index ab622e859..91c3c723c 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp @@ -1824,6 +1824,22 @@ void CIrrDeviceLinux::setWindowCaption(const wchar_t* text) #endif } +//! sets the class of the window +void CIrrDeviceLinux::setWindowClass(const char* text) +{ +#ifdef _IRR_COMPILE_WITH_X11_ + if (CreationParams.DriverType == video::EDT_NULL) + return; + + // Set class hints on Linux, used by Window Managers. + XClassHint* classhint = XAllocClassHint(); + classhint->res_name = (char*)text; + classhint->res_class = (char*)text; + XSetClassHint(display, window, classhint); + XFree(classhint); +#endif +} + //! presents a surface in the client area bool CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect* srcRect) diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h index 9d1a8688f..f79410b4c 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h @@ -68,6 +68,9 @@ namespace irr //! sets the caption of the window virtual void setWindowCaption(const wchar_t* text); + //! sets the class of the window + virtual void setWindowClass(const char* text); + //! returns if window is active. if not, nothing need to be drawn virtual bool isWindowActive() const; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h index c151f1d8e..99306a80e 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h @@ -44,6 +44,9 @@ namespace irr //! sets the caption of the window virtual void setWindowCaption(const wchar_t* text); + //! sets the class of the window + virtual void setWindowClass(const char* text) {} + //! returns if window is active. if not, nothing need to be drawn virtual bool isWindowActive() const; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp index ab38f810f..815572485 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp @@ -922,6 +922,15 @@ void CIrrDeviceWayland::setWindowCaption(const wchar_t* text) wl_shell_surface_set_title(m_shell_surface, title); } +//! sets the class of the window +void CIrrDeviceWayland::setWindowClass(const char* text) +{ + if (!m_shell_surface) + return; + + wl_shell_surface_set_class(m_shell_surface, text); +} + //! presents a surface in the client area bool CIrrDeviceWayland::present(video::IImage* image, void* windowId, core::rect* srcRect) diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h index b290e7c3a..37c0896b2 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h @@ -67,6 +67,9 @@ namespace irr //! sets the caption of the window virtual void setWindowCaption(const wchar_t* text); + //! sets the class of the window + virtual void setWindowClass(const char* text); + //! returns if window is active. if not, nothing need to be drawn virtual bool isWindowActive() const; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h index 16c5d5426..4ec40ea10 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWin32.h @@ -51,6 +51,9 @@ namespace irr //! sets the caption of the window virtual void setWindowCaption(const wchar_t* text); + //! sets the class of the window + virtual void setWindowClass(const char* text) {} + //! returns if window is active. if not, nothing need to be drawn virtual bool isWindowActive() const; diff --git a/lib/irrlicht/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h b/lib/irrlicht/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h index 755996cf9..0823a7b6e 100644 --- a/lib/irrlicht/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h +++ b/lib/irrlicht/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h @@ -50,6 +50,9 @@ namespace irr //! sets the caption of the window virtual void setWindowCaption(const wchar_t* text); + //! sets the class of the window + virtual void setWindowClass(const char* text) {} + //! returns if window is active. if not, nothing need to be drawn virtual bool isWindowActive() const; diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index a66ddb11e..7a80c90c6 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -716,21 +716,7 @@ void IrrDriver::initDevice() // Only change video driver settings if we are showing graphics if (!ProfileWorld::isNoGraphics()) { -#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(); - XClassHint* classhint = XAllocClassHint(); - classhint->res_name = (char*)"SuperTuxKart"; - classhint->res_class = (char*)"SuperTuxKart"; - XSetClassHint((Display*)videoData.OpenGLLinux.X11Display, - videoData.OpenGLLinux.X11Window, - classhint); - XFree(classhint); - } -#endif + m_device->setWindowClass("SuperTuxKart"); m_device->setWindowCaption(L"SuperTuxKart"); m_device->getVideoDriver() ->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);