1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56: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")})); QCommandLineOption fullscreenOption(QStringList({QSL("f"), QSL("fullscreen")}));
fullscreenOption.setDescription(QSL("Toggles fullscreen.")); fullscreenOption.setDescription(QSL("Toggles fullscreen."));
QCommandLineOption wmclassOption(QStringList({QSL("wmclass")}));
wmclassOption.setValueName(QSL("WM_CLASS"));
wmclassOption.setDescription(QSL("Application class (X11 only)."));
// Parser // Parser
QCommandLineParser parser; QCommandLineParser parser;
parser.setApplicationDescription(QSL("QtWebEngine based browser")); parser.setApplicationDescription(QSL("QtWebEngine based browser"));
@ -92,6 +96,7 @@ void CommandLineOptions::parseActions()
parser.addOption(currentTabOption); parser.addOption(currentTabOption);
parser.addOption(openWindowOption); parser.addOption(openWindowOption);
parser.addOption(fullscreenOption); parser.addOption(fullscreenOption);
parser.addOption(wmclassOption);
parser.addPositionalArgument(QSL("URL"), QSL("URLs to open"), QSL("[URL...]")); parser.addPositionalArgument(QSL("URL"), QSL("URLs to open"), QSL("[URL...]"));
// parse() and not process() so we can pass arbitrary options to Chromium // parse() and not process() so we can pass arbitrary options to Chromium
@ -186,6 +191,13 @@ void CommandLineOptions::parseActions()
m_actions.append(pair); 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()) if (parser.positionalArguments().isEmpty())
return; return;

View File

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

View File

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

View File

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

View File

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