diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,7 @@ NewStuff GlobalAccel XmlGui + Wayland ) # optional components diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -84,6 +84,7 @@ KF5::NewStuff KF5::GlobalAccel KF5::XmlGui + KF5::WaylandClient ) if(XCB_FOUND) diff --git a/src/QuickEditor/QuickEditor.h b/src/QuickEditor/QuickEditor.h --- a/src/QuickEditor/QuickEditor.h +++ b/src/QuickEditor/QuickEditor.h @@ -29,13 +29,19 @@ class QMouseEvent; +namespace KWayland { +namespace Client { +class PlasmaShell; +} +} + class QuickEditor: public QWidget { Q_OBJECT public: - explicit QuickEditor(const QPixmap &thePixmap, QWidget *parent = nullptr); + explicit QuickEditor(const QPixmap &thePixmap, KWayland::Client::PlasmaShell *plasmashell, QWidget *parent = nullptr); virtual ~QuickEditor() = default; private: diff --git a/src/QuickEditor/QuickEditor.cpp b/src/QuickEditor/QuickEditor.cpp --- a/src/QuickEditor/QuickEditor.cpp +++ b/src/QuickEditor/QuickEditor.cpp @@ -18,6 +18,8 @@ */ #include +#include +#include #include #include #include @@ -50,7 +52,7 @@ const int QuickEditor::magPixels = 16; const int QuickEditor::magOffset = 32; -QuickEditor::QuickEditor(const QPixmap& thePixmap, QWidget *parent) : +QuickEditor::QuickEditor(const QPixmap &thePixmap, KWayland::Client::PlasmaShell *plasmashell, QWidget *parent) : QWidget(parent), mMaskColor(QColor::fromRgbF(0, 0, 0, 0.15)), mStrokeColor(palette().highlight().color()), @@ -89,7 +91,14 @@ dprI = 1.0 / devicePixelRatioF(); setGeometry(0, 0, static_cast(mPixmap.width() * dprI), static_cast(mPixmap.height() * dprI)); - + if (plasmashell) { + using namespace KWayland::Client; + auto surface = Surface::fromQtWinId(this->winId()); + PlasmaShellSurface *plasmashellSurface = plasmashell->createSurface(surface, this); + plasmashellSurface->setRole(PlasmaShellSurface::Role::OnScreenDisplay); + plasmashellSurface->setPanelTakesFocus(true); + plasmashellSurface->setPosition(geometry().topLeft()); + } if (config->rememberLastRectangularRegion()) { QRect cropRegion = config->cropRegion(); if (!cropRegion.isEmpty()) { diff --git a/src/SpectacleCore.h b/src/SpectacleCore.h --- a/src/SpectacleCore.h +++ b/src/SpectacleCore.h @@ -30,6 +30,12 @@ #include +namespace KWayland { +namespace Client { +class PlasmaShell; +} +} + using MainWindowPtr = std::unique_ptr; using EditorPtr = std::unique_ptr; @@ -92,4 +98,5 @@ bool mIsGuiInited; bool mCopySaveLocationToClipboard; bool mCopyImageToClipboard; + KWayland::Client::PlasmaShell *mWaylandPlasmashell; }; diff --git a/src/SpectacleCore.cpp b/src/SpectacleCore.cpp --- a/src/SpectacleCore.cpp +++ b/src/SpectacleCore.cpp @@ -28,6 +28,9 @@ #include #include #include +#include +#include +#include #include #include @@ -52,7 +55,8 @@ mPlatform(loadPlatform()), mMainWindow(nullptr), mIsGuiInited(false), - mCopySaveLocationToClipboard(theCopyToClipboard) + mCopySaveLocationToClipboard(theCopyToClipboard), + mWaylandPlasmashell(nullptr) { auto lConfig = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); KConfigGroup lGuiConfig(lConfig, "GuiConfig"); @@ -89,6 +93,24 @@ connect(lExportManager, &ExportManager::forceNotify, this, &SpectacleCore::doNotify); connect(mPlatform.get(), &Platform::windowTitleChanged, lExportManager, &ExportManager::setWindowTitle); + // Needed so the QuickEditor can go fullscreen on wayland + if (KWindowSystem::isPlatformWayland()) { + using namespace KWayland::Client; + ConnectionThread *connection = ConnectionThread::fromApplication(this); + if (!connection) { + return; + } + Registry *registry = new Registry(this); + registry->create(connection); + connect(registry, &Registry::plasmaShellAnnounced, this, + [this, registry] (quint32 name, quint32 version) { + mWaylandPlasmashell = registry->createPlasmaShell(name, version, this); + } + ); + registry->setup(); + connection->roundtrip(); + } + switch (theStartMode) { case StartMode::DBus: break; @@ -224,7 +246,7 @@ if (lExportManager->captureMode() == Spectacle::CaptureMode::RectangularRegion) { if(!mQuickEditor) { - mQuickEditor = std::make_unique(thePixmap); + mQuickEditor = std::make_unique(thePixmap, mWaylandPlasmashell); connect(mQuickEditor.get(), &QuickEditor::grabDone, this, &SpectacleCore::screenshotUpdated); connect(mQuickEditor.get(), &QuickEditor::grabCancelled, this, &SpectacleCore::screenshotFailed); mQuickEditor->show();