Add WM_CLASS info to X11 window, controlled by XWMName .ini entry, defaulting to PRODUCT_ID.

Tested with: xdotool search --classname 'StepMania 5'
This commit is contained in:
Patrick McIlroy
2012-06-03 22:55:34 -07:00
parent a7f7a1fadb
commit ebf1bf6028
2 changed files with 15 additions and 0 deletions
+14
View File
@@ -1,6 +1,8 @@
#include "global.h"
#include "X11Helper.h"
#include "RageLog.h"
#include "ProductInfo.h"
#include "Preference.h"
#include "PrefsManager.h" // XXX: only used for m_bShowMouseCursor -aj
Display *X11Helper::Dpy = NULL;
@@ -9,6 +11,8 @@ Window X11Helper::Win = None;
static int ErrorCallback( Display*, XErrorEvent* );
static int FatalCallback( Display* );
static Preference<RString> g_XWMName( "XWMName", PRODUCT_ID );
bool X11Helper::OpenXConnection()
{
DEBUG_ASSERT( Dpy == NULL && Win == None );
@@ -61,6 +65,16 @@ bool X11Helper::MakeWindow( Window &win, int screenNum, int depth, Visual *visua
if( win == None )
return false;
XClassHint *hint = XAllocClassHint();
if ( hint == NULL ) {
LOG->Warn("Could not set class hint for X11 Window");
} else {
hint->res_name = (char*)g_XWMName.Get().c_str();
hint->res_class = (char*)PRODUCT_FAMILY;
XSetClassHint(Dpy, win, hint);
XFree(hint);
}
// Hide the mouse cursor in certain situations.
if( !PREFSMAN->m_bShowMouseCursor )
{
+1
View File
@@ -3,6 +3,7 @@
#define X11_HELPER_H
#include <X11/Xlib.h> // Window
#include <X11/Xutil.h>
namespace X11Helper
{
// All functions in here that return a bool return true on success, and