Skip to content

Commit

Permalink
[wmclass] work arround qt5 wm_class bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jul 6, 2013
1 parent 452668f commit 79b0ab5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
1 change: 0 additions & 1 deletion style/qtcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <QSplitter>
#include <QMdiSubWindow>
#include <QMainWindow>
#include <QStatusBar>
#include <QComboBox>
#include <QTreeView>
#include <QGroupBox>
Expand Down
16 changes: 8 additions & 8 deletions style/qtcurve_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <QSplitter>
#include <QMdiSubWindow>
#include <QMainWindow>
#include <QStatusBar>
#include <QComboBox>
#include <QTreeView>
#include <QGroupBox>
Expand Down Expand Up @@ -345,13 +344,11 @@ void Style::polish(QWidget *widget)

bool enableMouseOver(opts.highlightFactor || opts.coloredMouseOver);

/*
{
for(QWidget *w=widget; w; w=w->parentWidget())
printf("%s ", w->metaObject()->className());
printf("\n");
}
*/
// {
// for(QWidget *w=widget; w; w=w->parentWidget())
// printf("%s ", w->metaObject()->className());
// printf("\n");
// }

// 'Fix' konqueror's large menubar...
if(APP_KONQUEROR==theThemedApp && widget->parentWidget() &&
Expand All @@ -370,6 +367,9 @@ void Style::polish(QWidget *widget)
itsWindowManager->registerWidget(widget);
#ifdef QTC_X11
itsShadowHelper->registerWidget(widget);
if (widget->isWindow()) {
XcbUtils::setWindowWMClass(widget->winId());
}
#endif

// Need to register all widgets to blur helper, in order to have proper blur_behind region set have proper regions removed for opaque widgets.
Expand Down
1 change: 1 addition & 0 deletions style/qtcurve_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QToolButton>
#include <QWidget>
#include <QSplitter>
#include <QStatusBar>

class QToolBar;

Expand Down
1 change: 0 additions & 1 deletion style/qtcurve_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <QSplitter>
#include <QMdiSubWindow>
#include <QMainWindow>
#include <QStatusBar>
#include <QComboBox>
#include <QTreeView>
#include <QGroupBox>
Expand Down
22 changes: 19 additions & 3 deletions style/xcb_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
***************************************************************************/

#include "xcb_utils.h"
// #include <qpa/qplatformnativeinterface.h>
// #include <qpa/qplatformwindow.h>
#include <QApplication>
#include "qtcurve_p.h"

namespace QtCurve
{
Expand Down Expand Up @@ -49,5 +47,23 @@ getAtoms(size_t n, xcb_atom_t *atoms, const char *const names[], bool create)
free(cookies);
}

static QByteArray
getWMClass()
{
QByteArray appname = appName.toLocal8Bit();
return (appname + '\0' +
QCoreApplication::instance()->applicationName().toLocal8Bit());
}

void
setWindowWMClass(WId wid)
{
static const auto wmclassAtom = XcbUtils::getAtom("WM_CLASS");
static QByteArray wmclass = getWMClass();
XcbCallVoid(change_property, XCB_PROP_MODE_REPLACE,
wid, wmclassAtom, XCB_ATOM_STRING, 8, wmclass.count(),
wmclass.constData());
}

}
}
2 changes: 2 additions & 0 deletions style/xcb_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ getAtom(const char *name, bool create=false)
return atom;
}

void setWindowWMClass(WId id);

template<typename RetType, typename CookieType, typename... ArgTypes,
typename... ArgTypes2>
static inline RetType*
Expand Down

0 comments on commit 79b0ab5

Please sign in to comment.