1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

X11: Add --wmclass command line option

BUG: 400753
FIXED-IN: 3.1.0
This commit is contained in:
David Rosca 2018-12-24 14:47:43 +01:00
parent 51eb65ecec
commit cbb322c1a5
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
5 changed files with 29 additions and 3 deletions

View File

@ -75,6 +75,10 @@ void CommandLineOptions::parseActions()
QCommandLineOption fullscreenOption(QStringList({QSL("f"), QSL("fullscreen")}));
fullscreenOption.setDescription(QSL("Toggles fullscreen."));
QCommandLineOption wmclassOption(QStringList({QSL("wmclass")}));
wmclassOption.setValueName(QSL("WM_CLASS"));
wmclassOption.setDescription(QSL("Application class (X11 only)."));
// Parser
QCommandLineParser parser;
parser.setApplicationDescription(QSL("QtWebEngine based browser"));
@ -92,6 +96,7 @@ void CommandLineOptions::parseActions()
parser.addOption(currentTabOption);
parser.addOption(openWindowOption);
parser.addOption(fullscreenOption);
parser.addOption(wmclassOption);
parser.addPositionalArgument(QSL("URL"), QSL("URLs to open"), QSL("[URL...]"));
// parse() and not process() so we can pass arbitrary options to Chromium
@ -186,6 +191,13 @@ void CommandLineOptions::parseActions()
m_actions.append(pair);
}
if (parser.isSet(wmclassOption)) {
ActionPair pair;
pair.action = Qz::CL_WMClass;
pair.text = parser.value(wmclassOption);
m_actions.append(pair);
}
if (parser.positionalArguments().isEmpty())
return;

View File

@ -200,6 +200,9 @@ MainApplication::MainApplication(int &argc, char** argv)
case Qz::CL_ExitAction:
m_isClosing = true;
return;
case Qz::CL_WMClass:
m_wmClass = pair.text.toUtf8();
break;
default:
break;
}
@ -500,6 +503,11 @@ void MainApplication::setProxyStyle(ProxyStyle *style)
setStyle(style);
}
QByteArray MainApplication::wmClass() const
{
return m_wmClass;
}
History* MainApplication::history()
{
if (!m_history) {

View File

@ -91,6 +91,8 @@ public:
QString styleName() const;
void setProxyStyle(ProxyStyle *style);
QByteArray wmClass() const;
History* history();
Bookmarks* bookmarks();
@ -187,6 +189,8 @@ private:
AutoSaver* m_autoSaver;
ProxyStyle *m_proxyStyle = nullptr;
QByteArray m_wmClass;
QList<BrowserWindow*> m_windows;
QPointer<BrowserWindow> m_lastActiveWindow;

View File

@ -82,7 +82,8 @@ enum CommandLineAction {
CL_StartPrivateBrowsing,
CL_StartNewInstance,
CL_StartPortable,
CL_ExitAction
CL_ExitAction,
CL_WMClass
};
enum ObjectName {

View File

@ -18,6 +18,7 @@
#include "qztools.h"
#include "datapaths.h"
#include "settings.h"
#include "mainapplication.h"
#include <QTextDocument>
#include <QDateTime>
@ -862,8 +863,8 @@ void QzTools::setWmClass(const QString &name, const QWidget* widget)
if (QGuiApplication::platformName() != QL1S("xcb"))
return;
const QByteArray &nameData = name.toUtf8();
const QByteArray &classData = QByteArrayLiteral("Falkon");
const QByteArray nameData = name.toUtf8();
const QByteArray classData = mApp->wmClass().isEmpty() ? QByteArrayLiteral("Falkon") : mApp->wmClass();
uint32_t class_len = nameData.length() + 1 + classData.length() + 1;
char *class_hint = (char*) malloc(class_len);