Add a possibility to set a window class in irr device.
This makes one ugly #ifdef less in the irr_driver.cpp.
This commit is contained in:
parent
b5f2e4d163
commit
c8137fc0fa
@ -152,6 +152,10 @@ namespace irr
|
|||||||
/** \param text: New text of the window caption. */
|
/** \param text: New text of the window caption. */
|
||||||
virtual void setWindowCaption(const wchar_t* text) = 0;
|
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.
|
//! Returns if the window is active.
|
||||||
/** If the window is inactive,
|
/** If the window is inactive,
|
||||||
nothing needs to be drawn. So if you don't want to draw anything
|
nothing needs to be drawn. So if you don't want to draw anything
|
||||||
|
@ -35,6 +35,7 @@ namespace irr
|
|||||||
virtual void yield();
|
virtual void yield();
|
||||||
virtual void sleep(u32 timeMs, bool pauseTimer=false);
|
virtual void sleep(u32 timeMs, bool pauseTimer=false);
|
||||||
virtual void setWindowCaption(const wchar_t* text);
|
virtual void setWindowCaption(const wchar_t* text);
|
||||||
|
virtual void setWindowClass(const char* text) {}
|
||||||
virtual bool present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip);
|
virtual bool present(video::IImage* surface, void* windowId, core::rect<s32>* srcClip);
|
||||||
virtual bool isWindowActive() const;
|
virtual bool isWindowActive() const;
|
||||||
virtual bool isWindowFocused() const;
|
virtual bool isWindowFocused() const;
|
||||||
|
@ -59,6 +59,9 @@ namespace irr
|
|||||||
//! sets the caption of the window
|
//! sets the caption of the window
|
||||||
virtual void setWindowCaption(const wchar_t* text);
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
virtual bool isWindowActive() const;
|
||||||
|
|
||||||
|
@ -45,6 +45,9 @@ namespace irr
|
|||||||
//! sets the caption of the window
|
//! sets the caption of the window
|
||||||
virtual void setWindowCaption(const wchar_t* text);
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
virtual bool isWindowActive() const;
|
||||||
|
|
||||||
|
@ -1824,6 +1824,22 @@ void CIrrDeviceLinux::setWindowCaption(const wchar_t* text)
|
|||||||
#endif
|
#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
|
//! presents a surface in the client area
|
||||||
bool CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s32>* srcRect)
|
bool CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s32>* srcRect)
|
||||||
|
@ -68,6 +68,9 @@ namespace irr
|
|||||||
//! sets the caption of the window
|
//! sets the caption of the window
|
||||||
virtual void setWindowCaption(const wchar_t* text);
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
virtual bool isWindowActive() const;
|
||||||
|
|
||||||
|
@ -44,6 +44,9 @@ namespace irr
|
|||||||
//! sets the caption of the window
|
//! sets the caption of the window
|
||||||
virtual void setWindowCaption(const wchar_t* text);
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
virtual bool isWindowActive() const;
|
||||||
|
|
||||||
|
@ -922,6 +922,15 @@ void CIrrDeviceWayland::setWindowCaption(const wchar_t* text)
|
|||||||
wl_shell_surface_set_title(m_shell_surface, title);
|
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
|
//! presents a surface in the client area
|
||||||
bool CIrrDeviceWayland::present(video::IImage* image, void* windowId,
|
bool CIrrDeviceWayland::present(video::IImage* image, void* windowId,
|
||||||
core::rect<s32>* srcRect)
|
core::rect<s32>* srcRect)
|
||||||
|
@ -67,6 +67,9 @@ namespace irr
|
|||||||
//! sets the caption of the window
|
//! sets the caption of the window
|
||||||
virtual void setWindowCaption(const wchar_t* text);
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
virtual bool isWindowActive() const;
|
||||||
|
|
||||||
|
@ -51,6 +51,9 @@ namespace irr
|
|||||||
//! sets the caption of the window
|
//! sets the caption of the window
|
||||||
virtual void setWindowCaption(const wchar_t* text);
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
virtual bool isWindowActive() const;
|
||||||
|
|
||||||
|
@ -50,6 +50,9 @@ namespace irr
|
|||||||
//! sets the caption of the window
|
//! sets the caption of the window
|
||||||
virtual void setWindowCaption(const wchar_t* text);
|
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
|
//! returns if window is active. if not, nothing need to be drawn
|
||||||
virtual bool isWindowActive() const;
|
virtual bool isWindowActive() const;
|
||||||
|
|
||||||
|
@ -716,21 +716,7 @@ 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 defined(__linux__) && !defined(ANDROID) && !defined(SERVER_ONLY)
|
m_device->setWindowClass("SuperTuxKart");
|
||||||
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->setWindowCaption(L"SuperTuxKart");
|
m_device->setWindowCaption(L"SuperTuxKart");
|
||||||
m_device->getVideoDriver()
|
m_device->getVideoDriver()
|
||||||
->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
|
->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user