Skip to content

Commit

Permalink
Set WM_CLASS window hint for Xorg
Browse files Browse the repository at this point in the history
  • Loading branch information
kwolekr committed Dec 15, 2014
1 parent 8fe1d3f commit 8661b35
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.cpp
Expand Up @@ -1582,6 +1582,7 @@ ClientLauncher::~ClientLauncher()
device->drop();
}


bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
{
init_args(game_params, cmd_args);
Expand All @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions src/porting.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/porting.h
Expand Up @@ -411,6 +411,9 @@ inline const char * getPlatformName()
;
}

void setXorgClassHint(const video::SExposedVideoData &video_data,
const std::string &name);

} // namespace porting

#ifdef __ANDROID__
Expand Down

0 comments on commit 8661b35

Please sign in to comment.