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
This commit is contained in:
parent
31405ae10f
commit
d38bce776f
10 changed files with 45 additions and 26 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
//****************************************
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -166,7 +166,6 @@ private:
|
|||
};
|
||||
WindowMode m_windowMode = WindowMode::NoCapture;
|
||||
int m_fd = -1;
|
||||
QScopedPointer<EffectFrame> m_infoFrame;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -1239,12 +1239,26 @@ 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:
|
||||
/**
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
void setEngine(QQmlEngine *engine);
|
||||
|
||||
void setContainsPointer(bool contains);
|
||||
void setSkipCloseAnimation(bool skip);
|
||||
|
||||
Q_SIGNALS:
|
||||
void visibleChanged();
|
||||
|
|
3
osd.cpp
3
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);
|
||||
}
|
||||
|
||||
|
|
7
osd.h
7
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());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue