Set WM_CLASS window hint for Xorg
authorkwolekr <kwolekr@minetest.net>
Mon, 15 Dec 2014 18:47:31 +0000 (13:47 -0500)
committerkwolekr <kwolekr@minetest.net>
Mon, 15 Dec 2014 18:52:10 +0000 (13:52 -0500)
src/main.cpp
src/porting.cpp
src/porting.h

index ed9800f00b5b381babb8f2487bd36b8339b4d611..0c5f73b23ae3ef7bec7c14d90759f5d4ad54e4be 100644 (file)
@@ -1582,6 +1582,7 @@ ClientLauncher::~ClientLauncher()
                device->drop();
 }
 
+
 bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
 {
        init_args(game_params, cmd_args);
@@ -1602,11 +1603,14 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
                return true;
        }
 
-       if (device->getVideoDriver() == NULL) {
+       video::IVideoDriver *video_driver = device->getVideoDriver();
+       if (video_driver == NULL) {
                errorstream << "Could not initialize video driver." << std::endl;
                return false;
        }
 
+       porting::setXorgClassHint(video_driver->getExposedVideoData(), "Minetest");
+
        /*
                This changes the minimum allowed number of vertices in a VBO.
                Default is 500.
index 42ee2ffe2994c0b04060cff7a41d54bfea5ef945..e1a062ecd80aed8535f1db58b37b7531ffefb720 100644 (file)
@@ -36,6 +36,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
        #include <sys/utsname.h>
 #endif
 
+#if !defined(_WIN32) && !defined(__APPLE__) && \
+       !defined(__ANDROID__) && !defined(SERVER)
+       #define XORG_USED
+#endif
+
+#ifdef XORG_USED
+       #include <X11/Xlib.h>
+       #include <X11/Xutil.h>
+#endif
+
 #include "config.h"
 #include "debug.h"
 #include "filesys.h"
@@ -545,6 +555,20 @@ void initIrrlicht(irr::IrrlichtDevice * _device) {
        device = _device;
 }
 
+void setXorgClassHint(const video::SExposedVideoData &video_data,
+       const std::string &name)
+{
+#ifdef XORG_USED
+       XClassHint *classhint = XAllocClassHint();
+       classhint->res_name  = (char *)name.c_str();
+       classhint->res_class = (char *)name.c_str();
+
+       XSetClassHint((Display *)video_data.OpenGLLinux.X11Display,
+               video_data.OpenGLLinux.X11Window, classhint);
+       XFree(classhint);
+#endif
+}
+
 #ifndef SERVER
 v2u32 getWindowSize() {
        return device->getVideoDriver()->getScreenSize();
index b6f71103dac224a0a1bfc0d1894ecb650d699634..a184af8b86fcab3b1f60bc6d2ec94106908215b8 100644 (file)
@@ -411,6 +411,9 @@ inline const char * getPlatformName()
        ;
 }
 
+void setXorgClassHint(const video::SExposedVideoData &video_data,
+       const std::string &name);
+
 } // namespace porting
 
 #ifdef __ANDROID__