Skip to content

Commit 8661b35

Browse files
committedDec 15, 2014
Set WM_CLASS window hint for Xorg
1 parent 8fe1d3f commit 8661b35

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed
 

‎src/main.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,7 @@ ClientLauncher::~ClientLauncher()
15821582
device->drop();
15831583
}
15841584

1585+
15851586
bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
15861587
{
15871588
init_args(game_params, cmd_args);
@@ -1602,11 +1603,14 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
16021603
return true;
16031604
}
16041605

1605-
if (device->getVideoDriver() == NULL) {
1606+
video::IVideoDriver *video_driver = device->getVideoDriver();
1607+
if (video_driver == NULL) {
16061608
errorstream << "Could not initialize video driver." << std::endl;
16071609
return false;
16081610
}
16091611

1612+
porting::setXorgClassHint(video_driver->getExposedVideoData(), "Minetest");
1613+
16101614
/*
16111615
This changes the minimum allowed number of vertices in a VBO.
16121616
Default is 500.

‎src/porting.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3636
#include <sys/utsname.h>
3737
#endif
3838

39+
#if !defined(_WIN32) && !defined(__APPLE__) && \
40+
!defined(__ANDROID__) && !defined(SERVER)
41+
#define XORG_USED
42+
#endif
43+
44+
#ifdef XORG_USED
45+
#include <X11/Xlib.h>
46+
#include <X11/Xutil.h>
47+
#endif
48+
3949
#include "config.h"
4050
#include "debug.h"
4151
#include "filesys.h"
@@ -545,6 +555,20 @@ void initIrrlicht(irr::IrrlichtDevice * _device) {
545555
device = _device;
546556
}
547557

558+
void setXorgClassHint(const video::SExposedVideoData &video_data,
559+
const std::string &name)
560+
{
561+
#ifdef XORG_USED
562+
XClassHint *classhint = XAllocClassHint();
563+
classhint->res_name = (char *)name.c_str();
564+
classhint->res_class = (char *)name.c_str();
565+
566+
XSetClassHint((Display *)video_data.OpenGLLinux.X11Display,
567+
video_data.OpenGLLinux.X11Window, classhint);
568+
XFree(classhint);
569+
#endif
570+
}
571+
548572
#ifndef SERVER
549573
v2u32 getWindowSize() {
550574
return device->getVideoDriver()->getScreenSize();

‎src/porting.h

+3
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ inline const char * getPlatformName()
411411
;
412412
}
413413

414+
void setXorgClassHint(const video::SExposedVideoData &video_data,
415+
const std::string &name);
416+
414417
} // namespace porting
415418

416419
#ifdef __ANDROID__

0 commit comments

Comments
 (0)
Please sign in to comment.