summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp44
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp9
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp10
6 files changed, 62 insertions, 7 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 40e35acd5e..c4dd58667d 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -1232,6 +1232,7 @@ static const char * xcb_atomnames = {
// ICCCM window state
"WM_STATE\0"
"WM_CHANGE_STATE\0"
+ "WM_CLASS\0"
// Session management
"WM_CLIENT_LEADER\0"
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 1662e862f1..8f568c6c25 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -102,6 +102,7 @@ namespace QXcbAtom {
// ICCCM window state
WM_STATE,
WM_CHANGE_STATE,
+ WM_CLASS,
// Session management
WM_CLIENT_LEADER,
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 1c170d44e6..46077e2c3f 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -389,4 +389,48 @@ QVariant QXcbIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
return QPlatformIntegration::styleHint(hint);
}
+static QString argv0BaseName()
+{
+ QString result;
+ const QStringList arguments = QCoreApplication::arguments();
+ if (!arguments.isEmpty() && !arguments.front().isEmpty()) {
+ result = arguments.front();
+ const int lastSlashPos = result.lastIndexOf(QLatin1Char('/'));
+ if (lastSlashPos != -1)
+ result.remove(0, lastSlashPos + 1);
+ }
+ return result;
+}
+
+static const char resourceNameVar[] = "RESOURCE_NAME";
+
+QByteArray QXcbIntegration::wmClass() const
+{
+ if (m_wmClass.isEmpty()) {
+ // Instance name according to ICCCM 4.1.2.5
+ QString name;
+ if (name.isEmpty() && qEnvironmentVariableIsSet(resourceNameVar))
+ name = QString::fromLocal8Bit(qgetenv(resourceNameVar));
+ if (name.isEmpty())
+ name = argv0BaseName();
+
+ // Note: QCoreApplication::applicationName() cannot be called from the QGuiApplication constructor,
+ // hence this delayed initialization.
+ QString className = QCoreApplication::applicationName();
+ if (className.isEmpty()) {
+ className = argv0BaseName();
+ if (!className.isEmpty() && className.at(0).isLower())
+ className[0] = className.at(0).toUpper();
+ }
+
+ if (!name.isEmpty() && !className.isEmpty()) {
+ m_wmClass = name.toLocal8Bit();
+ m_wmClass.append('\0');
+ m_wmClass.append(className.toLocal8Bit());
+ m_wmClass.append('\0');
+ }
+ }
+ return m_wmClass;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index cc39fb1462..b884b3b7f2 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -99,6 +99,8 @@ public:
QXcbConnection *defaultConnection() const { return m_connections.first(); }
+ QByteArray wmClass() const;
+
private:
QList<QXcbConnection *> m_connections;
@@ -115,6 +117,8 @@ private:
QScopedPointer<QPlatformServices> m_services;
friend class QXcbConnection; // access QPlatformIntegration::screenAdded()
+
+ mutable QByteArray m_wmClass;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index 7d832a1c08..9e9fd2914f 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -95,12 +95,9 @@ QXcbNativeInterface::QXcbNativeInterface() :
void QXcbNativeInterface::beep() // For QApplication::beep()
{
-#ifdef XCB_USE_XLIB
- ::Display *display = (::Display *)nativeResourceForScreen(QByteArrayLiteral("display"), QGuiApplication::primaryScreen());
- XBell(display, 0);
-#else
- fputc(7, stdout);
-#endif
+ QPlatformScreen *screen = QGuiApplication::primaryScreen()->handle();
+ xcb_connection_t *connection = static_cast<QXcbScreen *>(screen)->xcb_connection();
+ xcb_bell(connection, 0);
}
void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resourceString)
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 3a19788316..0325338a13 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -379,6 +379,13 @@ void QXcbWindow::create()
m_syncValue.hi = 0;
m_syncValue.lo = 0;
+ const QByteArray wmClass = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration())->wmClass();
+ if (!wmClass.isEmpty()) {
+ Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE,
+ m_window, atom(QXcbAtom::WM_CLASS),
+ XCB_ATOM_STRING, 8, wmClass.size(), wmClass.constData()));
+ }
+
if (m_usingSyncProtocol) {
m_syncCounter = xcb_generate_id(xcb_connection());
Q_XCB_CALL(xcb_sync_create_counter(xcb_connection(), m_syncCounter, m_syncValue));
@@ -1636,7 +1643,8 @@ void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
{
if (window() != QGuiApplication::focusWindow()) {
QWindow *w = static_cast<QWindowPrivate *>(QObjectPrivate::get(window()))->eventReceiver();
- w->requestActivate();
+ if (!(w->flags() & Qt::WindowDoesNotAcceptFocus))
+ w->requestActivate();
}
updateNetWmUserTime(event->time);