aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <[email protected]>2017-01-11 20:14:36 +0100
committerMartin Gräßlin <[email protected]>2017-01-25 13:54:34 +0100
commitd38bce776fa2dda6288474c0484c8113fb99e5ef (patch)
treed5d40d1b8e3304d185b2b12c5aa6938fcb5a88a6
parent31405ae10f1d2a9e6f58b0f03ee92bd8b0c449bc (diff)
Add support for skip close animation to OnScreenMessage
Summary: This change adds support for marking the OnScreenMessage as it should skip close animation. The screenshot effect is adjusted to use the on screen message instead of the custom effect frame. Test Plan: Message window is not captured when taking screenshot Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D4091
-rw-r--r--autotests/mock_effectshandler.h2
-rw-r--r--effects.cpp8
-rw-r--r--effects.h2
-rw-r--r--effects/screenshot/screenshot.cpp24
-rw-r--r--effects/screenshot/screenshot.h1
-rw-r--r--libkwineffects/kwineffects.h16
-rw-r--r--onscreennotification.cpp7
-rw-r--r--onscreennotification.h1
-rw-r--r--osd.cpp3
-rw-r--r--osd.h7
10 files changed, 45 insertions, 26 deletions
diff --git a/autotests/mock_effectshandler.h b/autotests/mock_effectshandler.h
index 00e7c56..7c01b18 100644
--- a/autotests/mock_effectshandler.h
+++ b/autotests/mock_effectshandler.h
@@ -255,7 +255,7 @@ public:
Q_UNUSED(message)
Q_UNUSED(iconName)
}
- void hideOnScreenMessage() override {}
+ void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override { Q_UNUSED(flags)}
private:
bool m_animationsSuported = true;
diff --git a/effects.cpp b/effects.cpp
index f228fc4..354b083 100644
--- a/effects.cpp
+++ b/effects.cpp
@@ -1596,9 +1596,13 @@ void EffectsHandlerImpl::showOnScreenMessage(const QString &message, const QStri
OSD::show(message, iconName);
}
-void EffectsHandlerImpl::hideOnScreenMessage()
+void EffectsHandlerImpl::hideOnScreenMessage(OnScreenMessageHideFlags flags)
{
- OSD::hide();
+ OSD::HideFlags osdFlags;
+ if (flags.testFlag(OnScreenMessageHideFlag::SkipsCloseAnimation)) {
+ osdFlags |= OSD::HideFlag::SkipCloseAnimation;
+ }
+ OSD::hide(osdFlags);
}
//****************************************
diff --git a/effects.h b/effects.h
index c44a167..b1c9663 100644
--- a/effects.h
+++ b/effects.h
@@ -235,7 +235,7 @@ public:
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override;
void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override;
- void hideOnScreenMessage() override;
+ void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override;
Scene *scene() const {
return m_scene;
diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp
index 29dffe4..af1903e 100644
--- a/effects/screenshot/screenshot.cpp
+++ b/effects/screenshot/screenshot.cpp
@@ -91,10 +91,6 @@ void ScreenShotEffect::paintScreen(int mask, QRegion region, ScreenPaintData &da
{
m_cachedOutputGeometry = data.outputGeometry();
effects->paintScreen(mask, region, data);
-
- if (m_infoFrame) {
- m_infoFrame->render(region);
- }
}
void ScreenShotEffect::postPaintScreen()
@@ -401,29 +397,21 @@ void ScreenShotEffect::interactive(QDBusUnixFileDescriptor fd, int mask)
void ScreenShotEffect::showInfoMessage(InfoMessageMode mode)
{
- if (!m_infoFrame.isNull()) {
- return;
- }
- m_infoFrame.reset(effects->effectFrame(EffectFrameStyled, false));
- QFont font;
- font.setBold(true);
- m_infoFrame->setFont(font);
- QRect area = effects->clientArea(ScreenArea, effects->activeScreen(), effects->currentDesktop());
- m_infoFrame->setPosition(QPoint(area.x() + area.width() / 2, area.y() + area.height() / 3));
+ QString text;
switch (mode) {
case InfoMessageMode::Window:
- m_infoFrame->setText(i18n("Select window to screen shot with left click or enter.\nEscape or right click to cancel."));
+ text = i18n("Select window to screen shot with left click or enter.\nEscape or right click to cancel.");
break;
case InfoMessageMode::Screen:
- m_infoFrame->setText(i18n("Create screen shot with left click or enter.\nEscape or right click to cancel."));
+ text = i18n("Create screen shot with left click or enter.\nEscape or right click to cancel.");
break;
}
- effects->addRepaintFull();
+ effects->showOnScreenMessage(text, QStringLiteral("spectacle"));
}
void ScreenShotEffect::hideInfoMessage()
{
- m_infoFrame.reset();
+ effects->hideOnScreenMessage(EffectsHandler::OnScreenMessageHideFlag::SkipsCloseAnimation);
}
QString ScreenShotEffect::screenshotFullscreen(bool captureCursor)
@@ -639,7 +627,7 @@ void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h)
bool ScreenShotEffect::isActive() const
{
- return (m_scheduledScreenshot != NULL || !m_scheduledGeometry.isNull() || !m_infoFrame.isNull()) && !effects->isScreenLocked();
+ return (m_scheduledScreenshot != NULL || !m_scheduledGeometry.isNull()) && !effects->isScreenLocked();
}
void ScreenShotEffect::windowClosed( EffectWindow* w )
diff --git a/effects/screenshot/screenshot.h b/effects/screenshot/screenshot.h
index ef0a10f..7a9458a 100644
--- a/effects/screenshot/screenshot.h
+++ b/effects/screenshot/screenshot.h
@@ -166,7 +166,6 @@ private:
};
WindowMode m_windowMode = WindowMode::NoCapture;
int m_fd = -1;
- QScopedPointer<EffectFrame> m_infoFrame;
};
} // namespace
diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h
index 9b50d4e..92f32a2 100644
--- a/libkwineffects/kwineffects.h
+++ b/libkwineffects/kwineffects.h
@@ -1240,11 +1240,25 @@ public:
virtual void showOnScreenMessage(const QString &message, const QString &iconName = QString()) = 0;
/**
+ * Flags for how to hide a shown on-screen-message
+ * @see hideOnScreenMessage
+ * @since 5.9
+ **/
+ enum class OnScreenMessageHideFlag {
+ /**
+ * The on-screen-message should skip the close window animation.
+ * @see EffectWindow::skipsCloseAnimation
+ **/
+ SkipsCloseAnimation = 1
+ };
+ Q_DECLARE_FLAGS(OnScreenMessageHideFlags, OnScreenMessageHideFlag)
+ /**
* Hides a previously shown on-screen-message again.
+ * @param flags The flags for how to hide the message
* @see showOnScreenMessage
* @since 5.9
**/
- virtual void hideOnScreenMessage() = 0;
+ virtual void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) = 0;
Q_SIGNALS:
/**
diff --git a/onscreennotification.cpp b/onscreennotification.cpp
index b32349e..98adb00 100644
--- a/onscreennotification.cpp
+++ b/onscreennotification.cpp
@@ -236,4 +236,11 @@ void OnScreenNotification::setContainsPointer(bool contains)
m_animation->start();
}
+void OnScreenNotification::setSkipCloseAnimation(bool skip)
+{
+ if (QQuickWindow *w = qobject_cast<QQuickWindow*>(m_mainItem.data())) {
+ w->setProperty("KWIN_SKIP_CLOSE_ANIMATION", skip);
+ }
+}
+
#include "onscreennotification.moc"
diff --git a/onscreennotification.h b/onscreennotification.h
index 0c91612..92fddd0 100644
--- a/onscreennotification.h
+++ b/onscreennotification.h
@@ -63,6 +63,7 @@ public:
void setEngine(QQmlEngine *engine);
void setContainsPointer(bool contains);
+ void setSkipCloseAnimation(bool skip);
Q_SIGNALS:
void visibleChanged();
diff --git a/osd.cpp b/osd.cpp
index 8d2ec30..601b860 100644
--- a/osd.cpp
+++ b/osd.cpp
@@ -68,12 +68,13 @@ void show(const QString &message, const QString &iconName)
show(message, iconName, 0);
}
-void hide()
+void hide(HideFlags flags)
{
if (!kwinApp()->shouldUseWaylandForCompositing()) {
// FIXME: only supported on Wayland
return;
}
+ osd()->setSkipCloseAnimation(flags.testFlag(HideFlag::SkipCloseAnimation));
osd()->setVisible(false);
}
diff --git a/osd.h b/osd.h
index 234ca65..9e45822 100644
--- a/osd.h
+++ b/osd.h
@@ -22,6 +22,7 @@
#ifndef KWIN_OSD_H
#define KWIN_OSD_H
+#include <QFlags>
#include <QString>
namespace KWin
@@ -32,7 +33,11 @@ namespace OSD
void show(const QString &message, const QString &iconName = QString());
void show(const QString &message, int timeout);
void show(const QString &message, const QString &iconName, int timeout);
-void hide();
+enum class HideFlag {
+ SkipCloseAnimation = 1
+};
+Q_DECLARE_FLAGS(HideFlags, HideFlag)
+void hide(HideFlags flags = HideFlags());
}
}