From cb1064fd32d3ca7dea818233a5afe9a890205b3e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 Sep 2013 16:40:22 +0200 Subject: [PATCH] the desktop view exposes a way to be desktop win the desktop shell will set the window as a "desktop" window, always behind. some other shells will have the desktop as a normal window the api can still expand --- src/shell/desktopview.cpp | 51 ++++++++++++++++++- src/shell/desktopview.h | 15 ++++++ .../desktop/contents/views/Desktop.qml | 2 + 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/shell/desktopview.cpp b/src/shell/desktopview.cpp index 3c9eee47e..8147b1e18 100644 --- a/src/shell/desktopview.cpp +++ b/src/shell/desktopview.cpp @@ -19,11 +19,20 @@ #include "desktopview.h" #include "shellcorona.h" +#include +#include +#include + +#include + #include DesktopView::DesktopView(ShellCorona *corona, QWindow *parent) - : PlasmaQuickView(corona, parent) + : PlasmaQuickView(corona, parent), + m_stayBehind(false), + m_fillScreen(false) { + engine()->rootContext()->setContextProperty("desktop", this); setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml"))); } @@ -31,6 +40,46 @@ DesktopView::~DesktopView() { } + +bool DesktopView::stayBehind() const +{ + return m_stayBehind; +} + +void DesktopView::setStayBehind(bool stayBehind) +{ + if (stayBehind == m_stayBehind) { + return; + } + + if (stayBehind) { + KWindowSystem::setType(winId(), NET::Desktop); + } else { + KWindowSystem::setType(winId(), NET::Normal); + } + + m_stayBehind = stayBehind; + emit stayBehindChanged(); +} + +bool DesktopView::fillScreen() const +{ + return m_fillScreen; +} + +void DesktopView::setFillScreen(bool fillScreen) +{ + if (fillScreen == m_fillScreen) { + return; + } + + resize(screen()->geometry().width(), screen()->geometry().height()); + connect(screen(), &QScreen::geometryChanged, [=]{resize(screen()->geometry().width(), screen()->geometry().height());}); + + fillScreen = fillScreen; + emit fillScreenChanged(); +} + /* void DesktopView::showConfigurationInterface(Plasma::Applet *applet) { diff --git a/src/shell/desktopview.h b/src/shell/desktopview.h index 498dbd64c..f7cc6044e 100644 --- a/src/shell/desktopview.h +++ b/src/shell/desktopview.h @@ -29,19 +29,34 @@ class ShellCorona; class DesktopView : public PlasmaQuickView { Q_OBJECT + Q_PROPERTY(bool stayBehind READ stayBehind WRITE setStayBehind NOTIFY stayBehindChanged) + Q_PROPERTY(bool fillScreen READ fillScreen WRITE setFillScreen NOTIFY fillScreenChanged) public: explicit DesktopView(ShellCorona *corona, QWindow *parent = 0); virtual ~DesktopView(); + bool stayBehind() const; + void setStayBehind(bool stayBehind); + + bool fillScreen() const; + void setFillScreen(bool fillScreen); + protected Q_SLOTS: /** * It will be called when the configuration is requested + * FIXME: this should be moved here */ //virtual void showConfigurationInterface(Plasma::Applet *applet); +Q_SIGNALS: + void stayBehindChanged(); + void fillScreenChanged(); + private: QPointer m_configView; + bool m_stayBehind : 1; + bool m_fillScreen : 1; }; #endif // DESKTOVIEW_H diff --git a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml index c5bff200e..71c033de3 100644 --- a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml +++ b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml @@ -38,6 +38,8 @@ Rectangle { } Component.onCompleted: { + desktop.stayBehind = true; + desktop.fillScreen = true; print("View QML loaded") } }