diff options
Diffstat (limited to 'src')
8 files changed, 37 insertions, 2 deletions
diff --git a/src/compositor/compositor_api/waylandsurface.cpp b/src/compositor/compositor_api/waylandsurface.cpp index 33032e034..972ae451b 100644 --- a/src/compositor/compositor_api/waylandsurface.cpp +++ b/src/compositor/compositor_api/waylandsurface.cpp @@ -311,6 +311,12 @@ void WaylandSurface::sendOnScreenVisibilityChange(bool visible) d->surface->extendedSurface()->sendOnScreenVisibility(visible); } +QString WaylandSurface::className() const +{ + Q_D(const WaylandSurface); + return d->surface->className(); +} + QString WaylandSurface::title() const { Q_D(const WaylandSurface); diff --git a/src/compositor/compositor_api/waylandsurface.h b/src/compositor/compositor_api/waylandsurface.h index 6cfe084a9..ff3eb47fa 100644 --- a/src/compositor/compositor_api/waylandsurface.h +++ b/src/compositor/compositor_api/waylandsurface.h @@ -74,6 +74,7 @@ class Q_COMPOSITOR_EXPORT WaylandSurface : public QObject Q_PROPERTY(QPointF pos READ pos WRITE setPos NOTIFY posChanged) Q_PROPERTY(WaylandSurface::WindowFlags windowFlags READ windowFlags NOTIFY windowFlagsChanged) Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation NOTIFY contentOrientationChanged) + Q_PROPERTY(QString className READ className NOTIFY classNameChanged) Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask NOTIFY orientationUpdateMaskChanged) @@ -146,6 +147,8 @@ public: WaylandCompositor *compositor() const; + QString className() const; + QString title() const; bool transientInactive() const; @@ -162,6 +165,7 @@ signals: void contentOrientationChanged(); void orientationUpdateMaskChanged(); void extendedSurfaceReady(); + void classNameChanged(); void titleChanged(); }; diff --git a/src/compositor/wayland_wrapper/wlshellsurface.cpp b/src/compositor/wayland_wrapper/wlshellsurface.cpp index 8f837fc7a..aed1ee64f 100644 --- a/src/compositor/wayland_wrapper/wlshellsurface.cpp +++ b/src/compositor/wayland_wrapper/wlshellsurface.cpp @@ -284,8 +284,8 @@ void ShellSurface::set_class(struct wl_client *client, const char *class_) { Q_UNUSED(client); - Q_UNUSED(resource); - Q_UNUSED(class_); + ShellSurface *self = static_cast<ShellSurface *>(resource->data); + self->surface()->setClassName(QString::fromUtf8(class_)); } const struct wl_shell_surface_interface ShellSurface::shell_surface_interface = { diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index d05f36b52..d0586a90b 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -501,6 +501,14 @@ void Surface::surface_commit(wl_client *client, wl_resource *resource) resolve<Surface>(resource)->commit(); } +void Surface::setClassName(const QString &className) +{ + if (m_className != className) { + m_className = className; + emit waylandSurface()->classNameChanged(); + } +} + void Surface::setTitle(const QString &title) { if (m_title != title) { diff --git a/src/compositor/wayland_wrapper/wlsurface.h b/src/compositor/wayland_wrapper/wlsurface.h index 642e8f790..8ec87fa36 100644 --- a/src/compositor/wayland_wrapper/wlsurface.h +++ b/src/compositor/wayland_wrapper/wlsurface.h @@ -123,6 +123,9 @@ public: static const struct wl_surface_interface surface_interface; + QString className() const { return m_className; } + void setClassName(const QString &className); + QString title() const { return m_title; } void setTitle(const QString &title); @@ -157,6 +160,7 @@ private: QPointF m_position; QSize m_size; + QString m_className; QString m_title; bool m_transientInactive; diff --git a/src/plugins/platforms/wayland/qwaylandshellsurface.cpp b/src/plugins/platforms/wayland/qwaylandshellsurface.cpp index 60176ef88..de0101f9b 100644 --- a/src/plugins/platforms/wayland/qwaylandshellsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandshellsurface.cpp @@ -107,6 +107,11 @@ void QWaylandShellSurface::updateTransientParent(QWindow *parent) flags); } +void QWaylandShellSurface::setClassName(const char *_class) +{ + wl_shell_surface_set_class(m_shell_surface, _class); +} + void QWaylandShellSurface::setTitle(const char *title) { wl_shell_surface_set_title(m_shell_surface, title); diff --git a/src/plugins/platforms/wayland/qwaylandshellsurface.h b/src/plugins/platforms/wayland/qwaylandshellsurface.h index 4772e69be..d18bda36d 100644 --- a/src/plugins/platforms/wayland/qwaylandshellsurface.h +++ b/src/plugins/platforms/wayland/qwaylandshellsurface.h @@ -64,6 +64,8 @@ public: struct wl_shell_surface *handle() const { return m_shell_surface; } + void setClassName(const char *_class); + void setTitle(const char *title); private: diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 8bb135675..1e48bfdea 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -51,6 +51,7 @@ #include "qwaylandsubsurface.h" #include "qwaylanddecoration.h" +#include <QtCore/QFileInfo> #include <QtGui/QWindow> #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT @@ -92,6 +93,11 @@ QWaylandWindow::QWaylandWindow(QWindow *window) mDisplay->windowManagerIntegration()->authenticateWithToken(); #endif + // Set surface class to the .desktop file name (obtained from executable name) + QFileInfo exeFileInfo(qApp->applicationFilePath()); + QString className = exeFileInfo.baseName() + QLatin1String(".desktop"); + mShellSurface->setClassName(className.toUtf8().constData()); + if (parent() && mSubSurfaceWindow) { mSubSurfaceWindow->setParent(static_cast<const QWaylandWindow *>(parent())); } else if (window->transientParent()) { |