From dccf8d9787d845c77796f794ac7998491d1bc4ff Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 7 Jul 2013 12:32:55 +0200 Subject: [PATCH] X11: Set correct WM_CLASS property to windows Closes #968 --- CHANGELOG | 1 + src/lib/app/qupzilla.cpp | 4 ++++ src/lib/cookies/cookiemanager.cpp | 4 ++++ src/lib/other/browsinglibrary.cpp | 5 +++++ src/lib/preferences/preferences.cpp | 4 ++++ src/lib/tools/qztools.cpp | 15 ++++++++++++++- src/lib/tools/qztools.h | 3 ++- src/lib/webview/siteinfo.cpp | 4 ++++ 8 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c26734ed1..6e1ef665e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ Version 1.5.0 * GreaseMonkey: fixed userscripts when first loading plugin * oxygen: set rounded corners for tooltips * oxygen: workaround for transparent background of tooltips + * X11: Set correct WM_CLASS property to windows * fixed: size of preferences dialog on low-res screens * fixed: loading plugins with relative paths in portable build diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 41151c29d..955055284 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -152,6 +152,10 @@ QupZilla::QupZilla(Qz::BrowserWindow type, QUrl startUrl) connect(mApp, SIGNAL(message(Qz::AppMessageType,bool)), this, SLOT(receiveMessage(Qz::AppMessageType,bool))); QTimer::singleShot(0, this, SLOT(postLaunch())); + +#if defined(QZ_WS_X11) && !defined(NO_X11) + QzTools::setWmClass("Browser", this); +#endif } void QupZilla::openWithTab(WebTab* tab) diff --git a/src/lib/cookies/cookiemanager.cpp b/src/lib/cookies/cookiemanager.cpp index 171df771d..c3cfd58da 100644 --- a/src/lib/cookies/cookiemanager.cpp +++ b/src/lib/cookies/cookiemanager.cpp @@ -76,6 +76,10 @@ CookieManager::CookieManager(QWidget* parent) QShortcut* removeShortcut = new QShortcut(QKeySequence("Del"), this); connect(removeShortcut, SIGNAL(activated()), this, SLOT(deletePressed())); + +#if defined(QZ_WS_X11) && !defined(NO_X11) + QzTools::setWmClass("Cookies", this); +#endif } void CookieManager::removeAll() diff --git a/src/lib/other/browsinglibrary.cpp b/src/lib/other/browsinglibrary.cpp index c1ed2cc50..b6c19c3d5 100644 --- a/src/lib/other/browsinglibrary.cpp +++ b/src/lib/other/browsinglibrary.cpp @@ -58,6 +58,11 @@ BrowsingLibrary::BrowsingLibrary(QupZilla* mainClass, QWidget* parent) connect(ui->tabs, SIGNAL(CurrentChanged(int)), this, SLOT(currentIndexChanged(int))); connect(ui->searchLine, SIGNAL(textChanged(QString)), this, SLOT(search())); + + +#if defined(QZ_WS_X11) && !defined(NO_X11) + QzTools::setWmClass("Browsing Library", this); +#endif } void BrowsingLibrary::currentIndexChanged(int index) diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index e3ddd1b51..7fcd2da42 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -480,6 +480,10 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) #if QTWEBKIT_TO_2_2 ui->html5permissions->setDisabled(true); #endif + +#if defined(QZ_WS_X11) && !defined(NO_X11) + QzTools::setWmClass("Preferences", this); +#endif } void Preferences::showStackedPage(QListWidgetItem* item) diff --git a/src/lib/tools/qztools.cpp b/src/lib/tools/qztools.cpp index f2b920c61..c11e839e5 100644 --- a/src/lib/tools/qztools.cpp +++ b/src/lib/tools/qztools.cpp @@ -44,6 +44,8 @@ #include #elif !defined(NO_X11) #include +#include +#include #endif #ifdef Q_OS_WIN @@ -645,7 +647,7 @@ QString QzTools::escape(const QString &string) } #if defined(QZ_WS_X11) && !defined(NO_X11) -void* QzTools::X11Display(const QWidget* widget) +Display* QzTools::X11Display(const QWidget* widget) { Q_UNUSED(widget) @@ -655,6 +657,17 @@ void* QzTools::X11Display(const QWidget* widget) return QX11Info::display(); #endif } + +void QzTools::setWmClass(const QString &name, const QWidget* widget) +{ + char* namestr = (char*) malloc(name.size() + 1); + strncpy(namestr, name.toUtf8().constData(), name.size() + 1); + + XClassHint classHint; + classHint.res_name = namestr; + classHint.res_class = const_cast("QupZilla"); + XSetClassHint(X11Display(widget), widget->winId(), &classHint); +} #endif QString QzTools::operatingSystem() diff --git a/src/lib/tools/qztools.h b/src/lib/tools/qztools.h index f5cbda307..3ad25a05d 100644 --- a/src/lib/tools/qztools.h +++ b/src/lib/tools/qztools.h @@ -74,7 +74,8 @@ bool QT_QUPZILLA_EXPORT isCertificateValid(const QSslCertificate &cert); QString QT_QUPZILLA_EXPORT escape(const QString &string); #if defined(QZ_WS_X11) && !defined(NO_X11) -void QT_QUPZILLA_EXPORT* X11Display(const QWidget* widget); +Display* X11Display(const QWidget* widget); +void QT_QUPZILLA_EXPORT setWmClass(const QString &name, const QWidget* widget); #endif template diff --git a/src/lib/webview/siteinfo.cpp b/src/lib/webview/siteinfo.cpp index 1aea7f276..a86e93502 100644 --- a/src/lib/webview/siteinfo.cpp +++ b/src/lib/webview/siteinfo.cpp @@ -176,6 +176,10 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) ui->treeImages->sortByColumn(-1); ui->treeTags->sortByColumn(-1); + +#if defined(QZ_WS_X11) && !defined(NO_X11) + QzTools::setWmClass("Site Info", this); +#endif } void SiteInfo::imagesCustomContextMenuRequested(const QPoint &p)