kwin/autotests/onscreennotificationtest.cpp

126 lines
4.0 KiB
C++
Raw Normal View History

Introduce a KWin internal on-screen-notification service Summary: Recently we noticed that there are multiple areas where KWin needs to inform the user about how to operate. Examples are: * Screenshot * ColorPicker * Pointer constraint enabled * Pointer constraint about to be removed * Kill Window For Screenshot and ColorPicker we used an EffectFrame to render it. But this is not an optimal solution as it's lacking many features we would need. We cannot properly use it from within KWin core, we cannot implement features like hide on mouse over, etc. etc. This change introduces an OnScreenNotification which supports: * showing an icon * showing a message * timeout It is Qml styled, so that it can be easily adjusted. This is a big improvement over the EffectFrame solution. The Qml file creates a Plasma Dialog of type OSD. Thus KWin places it like the normal OSD windows and also looks kind of similar. In the case of KWin the focus is more on the message, than an icon, so the icon is placed left of the text. While the OnScreenNotification is supposed to be used like a singleton, it doesn't use the KWin singleton pattern. Instead a small wrapper namespace OSD is introduced which provides a convenient API for KWin internal areas to show/hide the notification. By not using the KWin singleton pattern, the OnScreenNotification does not depend on any other parts of KWin and can be easily unit-tested. A few features are still missing and will be added in further commits: * hide-out on mouse over * optional skip close animation (needed for screenshot) * X11 support (not that important as it's mostly for Wayland features) Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3723
2016-12-18 13:53:50 +03:00
/*
2020-08-03 01:22:19 +03:00
SPDX-FileCopyrightText: 2016 Martin Graesslin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
Introduce a KWin internal on-screen-notification service Summary: Recently we noticed that there are multiple areas where KWin needs to inform the user about how to operate. Examples are: * Screenshot * ColorPicker * Pointer constraint enabled * Pointer constraint about to be removed * Kill Window For Screenshot and ColorPicker we used an EffectFrame to render it. But this is not an optimal solution as it's lacking many features we would need. We cannot properly use it from within KWin core, we cannot implement features like hide on mouse over, etc. etc. This change introduces an OnScreenNotification which supports: * showing an icon * showing a message * timeout It is Qml styled, so that it can be easily adjusted. This is a big improvement over the EffectFrame solution. The Qml file creates a Plasma Dialog of type OSD. Thus KWin places it like the normal OSD windows and also looks kind of similar. In the case of KWin the focus is more on the message, than an icon, so the icon is placed left of the text. While the OnScreenNotification is supposed to be used like a singleton, it doesn't use the KWin singleton pattern. Instead a small wrapper namespace OSD is introduced which provides a convenient API for KWin internal areas to show/hide the notification. By not using the KWin singleton pattern, the OnScreenNotification does not depend on any other parts of KWin and can be easily unit-tested. A few features are still missing and will be added in further commits: * hide-out on mouse over * optional skip close animation (needed for screenshot) * X11 support (not that important as it's mostly for Wayland features) Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3723
2016-12-18 13:53:50 +03:00
#include "onscreennotificationtest.h"
#include "../onscreennotification.h"
#include "../input.h"
Introduce a KWin internal on-screen-notification service Summary: Recently we noticed that there are multiple areas where KWin needs to inform the user about how to operate. Examples are: * Screenshot * ColorPicker * Pointer constraint enabled * Pointer constraint about to be removed * Kill Window For Screenshot and ColorPicker we used an EffectFrame to render it. But this is not an optimal solution as it's lacking many features we would need. We cannot properly use it from within KWin core, we cannot implement features like hide on mouse over, etc. etc. This change introduces an OnScreenNotification which supports: * showing an icon * showing a message * timeout It is Qml styled, so that it can be easily adjusted. This is a big improvement over the EffectFrame solution. The Qml file creates a Plasma Dialog of type OSD. Thus KWin places it like the normal OSD windows and also looks kind of similar. In the case of KWin the focus is more on the message, than an icon, so the icon is placed left of the text. While the OnScreenNotification is supposed to be used like a singleton, it doesn't use the KWin singleton pattern. Instead a small wrapper namespace OSD is introduced which provides a convenient API for KWin internal areas to show/hide the notification. By not using the KWin singleton pattern, the OnScreenNotification does not depend on any other parts of KWin and can be easily unit-tested. A few features are still missing and will be added in further commits: * hide-out on mouse over * optional skip close animation (needed for screenshot) * X11 support (not that important as it's mostly for Wayland features) Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3723
2016-12-18 13:53:50 +03:00
#include <KSharedConfig>
[autotests] Disable QtQuick in OnScreenNotificationTest Unfortunately Qt triggers an ASAN error in it's opengl implementation. As we don't really need the visible output in the test, disable QML. While this is unfortunate, it's better than a false-positive failing test. Output from build.kde.org: 18:15:51 ================================================================= 18:15:51 ==13802==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x614000027640 in thread T0: 18:15:51 object passed to delete has wrong type: 18:15:51 size of the allocated type: 400 bytes; 18:15:51 size of the deallocated type: 16 bytes. 18:15:51 #0 0x7fc1632614b2 in operator delete(void*, unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9a4b2) 18:15:51 #1 0x7fc1624f947d in QOpenGLVersionFunctionsStorage::~QOpenGLVersionFunctionsStorage() opengl/qopenglversionfunctions.cpp:81 18:15:51 #2 0x7fc1621c1315 in QOpenGLContextPrivate::~QOpenGLContextPrivate() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Gui.so.5+0x172315) 18:15:51 #3 0x7fc1621c1365 in QOpenGLContextPrivate::~QOpenGLContextPrivate() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Gui.so.5+0x172365) 18:15:51 #4 0x7fc161701e93 in QScopedPointerDeleter<QObjectData>::cleanup(QObjectData*) (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Core.so.5+0x363e93) 18:15:51 #5 0x7fc1617002c0 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::~QScopedPointer() ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:107 18:15:51 #6 0x7fc1616f4d20 in QObject::~QObject() kernel/qobject.cpp:900 18:15:51 #7 0x7fc1621beabf in QOpenGLContext::~QOpenGLContext() kernel/qopenglcontext.cpp:689 18:15:51 #8 0x7fc1621beaf3 in QOpenGLContext::~QOpenGLContext() kernel/qopenglcontext.cpp:696 18:15:51 #9 0x7fc162df817d in QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow*) scenegraph/qsgrenderloop.cpp:323 18:15:51 #10 0x7fc162e3ed8f in QQuickWindow::~QQuickWindow() items/qquickwindow.cpp:1237 18:15:51 #11 0x7fc151a105c1 in PlasmaQuick::Dialog::~Dialog() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/libKF5PlasmaQuick.so.5+0x1235c1) 18:15:51 #12 0x7fc151f4bce4 in QQmlPrivate::QQmlElement<PlasmaQuick::Dialog>::~QQmlElement() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/qml/org/kde/plasma/core/libcorebindingsplugin.so+0x162ce4) 18:15:51 #13 0x7fc151f4bd6d in QQmlPrivate::QQmlElement<PlasmaQuick::Dialog>::~QQmlElement() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/qml/org/kde/plasma/core/libcorebindingsplugin.so+0x162d6d) 18:15:51 #14 0x41f82f in QScopedPointerDeleter<QObject>::cleanup(QObject*) /srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/include/QtCore/qscopedpointer.h:60 18:15:51 #15 0x41e7a1 in QScopedPointer<QObject, QScopedPointerDeleter<QObject> >::~QScopedPointer() /srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/include/QtCore/qscopedpointer.h:107 18:15:51 #16 0x41c6b0 in KWin::OnScreenNotification::~OnScreenNotification() /home/jenkins/sources/kwin/kf5-qt5/onscreennotification.cpp:55 18:15:51 #17 0x410349 in OnScreenNotificationTest::show() /home/jenkins/sources/kwin/kf5-qt5/autotests/onscreennotificationtest.cpp:42 18:15:51 #18 0x42095f in OnScreenNotificationTest::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/jenkins/sources/kwin/kf5-qt5/build/autotests/moc_onscreennotificationtest.cpp:80 18:15:51 #19 0x7fc1616c3bda in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const kernel/qmetaobject.cpp:2222 18:15:51 #20 0x7fc1642f776c in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Test.so.5+0x1c76c) 18:15:51 #21 0x7fc1642f0820 in QTest::TestMethods::invokeTestOnData(int) const /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:800 18:15:51 #22 0x7fc1642f1353 in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:981 18:15:51 #23 0x7fc1642f25d6 in QTest::TestMethods::invokeTests(QObject*) const /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:1314 18:15:51 #24 0x7fc1642f31f7 in QTest::qExec(QObject*, int, char**) /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:1724 18:15:51 #25 0x40f5e4 in main /home/jenkins/sources/kwin/kf5-qt5/autotests/onscreennotificationtest.cpp:31 18:15:51 #26 0x7fc160a5babf in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20abf) 18:15:51 #27 0x40d118 in _start (/home/jenkins/sources/kwin/kf5-qt5/build/autotests/testOnScreenNotification+0x40d118) 18:15:51 18:15:51 0x614000027640 is located 0 bytes inside of 400-byte region [0x614000027640,0x6140000277d0) 18:15:51 allocated by thread T0 here: 18:15:51 #0 0x7fc1632608b2 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x998b2) 18:15:51 #1 0x7fc1624f9563 in QOpenGLVersionFunctionsStorage::backend(QOpenGLContext*, QOpenGLVersionFunctionsBackend::Version) opengl/qopenglversionfunctions.cpp:108 18:15:51 #2 0x7fc1624f9b10 in QAbstractOpenGLFunctionsPrivate::functionsBackend(QOpenGLContext*, QOpenGLVersionFunctionsBackend::Version) opengl/qopenglversionfunctions.cpp:122 18:15:51 #3 0x7fc16251475d in QOpenGLFunctions_1_0::initializeOpenGLFunctions() opengl/qopenglfunctions_1_0.cpp:100 18:15:51 #4 0x7fc1621bee83 in QOpenGLContext::versionFunctions(QOpenGLVersionProfile const&) const kernel/qopenglcontext.cpp:862 18:15:51 #5 0x7fc1621c1dbe in QOpenGLFunctions_1_0* QOpenGLContext::versionFunctions<QOpenGLFunctions_1_0>() const (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Gui.so.5+0x172dbe) 18:15:51 #6 0x7fc1621be166 in QOpenGLContextPrivate::maxTextureSize() kernel/qopenglcontext.cpp:382 18:15:51 #7 0x7fc1624df66a in QOpenGLTextureGlyphCache::maxTextureHeight() const opengl/qopengltextureglyphcache.cpp:459 18:15:51 #8 0x7fc162467acf in QTextureGlyphCache::populate(QFontEngine*, int, unsigned int const*, QFixedPoint const*) painting/qtextureglyphcache.cpp:208 18:15:51 #9 0x7fc162dddcfa in QSGTextMaskMaterial::populate(QPointF const&, QVector<unsigned int> const&, QVector<QPointF> const&, QSGGeometry*, QRectF*, QPointF*, QMargins const&) scenegraph/qsgdefaultglyphnode_p.cpp:456 18:15:51 #10 0x7fc162ddbc2b in QSGDefaultGlyphNode::update() scenegraph/qsgdefaultglyphnode.cpp:127 18:15:51 #11 0x7fc162ea3fb9 in QQuickTextNode::addGlyphs(QPointF const&, QGlyphRun const&, QColor const&, QQuickText::TextStyle, QColor const&, QSGNode*) items/qquicktextnode.cpp:115 18:15:51 #12 0x7fc162eaa7f6 in QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode*, QQuickText::TextStyle, QColor const&) items/qquicktextnodeengine.cpp:777 18:15:51 #13 0x7fc162ea4baa in QQuickTextNode::addTextLayout(QPointF const&, QTextLayout*, QColor const&, QQuickText::TextStyle, QColor const&, QColor const&, QColor const&, QColor const&, int, int, int, int) items/qquicktextnode.cpp:265 18:15:51 #14 0x7fc162ea02f9 in QQuickText::updatePaintNode(QSGNode*, QQuickItem::UpdatePaintNodeData*) items/qquicktext.cpp:2304 18:15:51 #15 0x7fc162e48a5f in QQuickWindowPrivate::updateDirtyNode(QQuickItem*) items/qquickwindow.cpp:3104 18:15:51 #16 0x7fc162e476a5 in QQuickWindowPrivate::updateDirtyNodes() items/qquickwindow.cpp:2849 18:15:51 #17 0x7fc162e3a8d2 in QQuickWindowPrivate::syncSceneGraph() items/qquickwindow.cpp:419 18:15:51 #18 0x7fc162df86bc in QSGGuiThreadRenderLoop::renderWindow(QQuickWindow*) scenegraph/qsgrenderloop.cpp:391 18:15:51 #19 0x7fc162df8c95 in QSGGuiThreadRenderLoop::exposureChanged(QQuickWindow*) scenegraph/qsgrenderloop.cpp:442 18:15:51 #20 0x7fc162e39e45 in QQuickWindow::exposeEvent(QExposeEvent*) items/qquickwindow.cpp:216 18:15:51 #21 0x7fc16217600d in QWindow::event(QEvent*) kernel/qwindow.cpp:2105 18:15:51 #22 0x7fc162e3f69e in QQuickWindow::event(QEvent*) items/qquickwindow.cpp:1537 18:15:51 #23 0x7fc151a17911 in PlasmaQuick::Dialog::event(QEvent*) (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/libKF5PlasmaQuick.so.5+0x12a911) 18:15:51 #24 0x7fc1616b69a7 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) kernel/qcoreapplication.cpp:1122 18:15:51 #25 0x7fc1616b65d1 in doNotify kernel/qcoreapplication.cpp:1063 18:15:51 #26 0x7fc1616b6535 in QCoreApplication::notify(QObject*, QEvent*) kernel/qcoreapplication.cpp:1049 18:15:51 #27 0x7fc1621623ef in QGuiApplication::notify(QObject*, QEvent*) kernel/qguiapplication.cpp:1648 18:15:51 #28 0x7fc1616b64b2 in QCoreApplication::notifyInternal2(QObject*, QEvent*) kernel/qcoreapplication.cpp:988 18:15:51 #29 0x7fc16216ac69 in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:234 18:15:51 18:15:51 SUMMARY: AddressSanitizer: new-delete-type-mismatch ??:0 operator delete(void*, unsigned long) 18:15:51 ==13802==HINT: if you don't care about these warnings you may set ASAN_OPTIONS=new_delete_type_mismatch=0 18:15:51 ==13802==ABORTING
2016-12-22 21:25:12 +03:00
#include <KConfigGroup>
Introduce a KWin internal on-screen-notification service Summary: Recently we noticed that there are multiple areas where KWin needs to inform the user about how to operate. Examples are: * Screenshot * ColorPicker * Pointer constraint enabled * Pointer constraint about to be removed * Kill Window For Screenshot and ColorPicker we used an EffectFrame to render it. But this is not an optimal solution as it's lacking many features we would need. We cannot properly use it from within KWin core, we cannot implement features like hide on mouse over, etc. etc. This change introduces an OnScreenNotification which supports: * showing an icon * showing a message * timeout It is Qml styled, so that it can be easily adjusted. This is a big improvement over the EffectFrame solution. The Qml file creates a Plasma Dialog of type OSD. Thus KWin places it like the normal OSD windows and also looks kind of similar. In the case of KWin the focus is more on the message, than an icon, so the icon is placed left of the text. While the OnScreenNotification is supposed to be used like a singleton, it doesn't use the KWin singleton pattern. Instead a small wrapper namespace OSD is introduced which provides a convenient API for KWin internal areas to show/hide the notification. By not using the KWin singleton pattern, the OnScreenNotification does not depend on any other parts of KWin and can be easily unit-tested. A few features are still missing and will be added in further commits: * hide-out on mouse over * optional skip close animation (needed for screenshot) * X11 support (not that important as it's mostly for Wayland features) Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3723
2016-12-18 13:53:50 +03:00
#include <QQmlEngine>
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(OnScreenNotificationTest);
namespace KWin
{
void InputRedirection::installInputEventSpy(InputEventSpy *spy)
{
Q_UNUSED(spy);
}
void InputRedirection::uninstallInputEventSpy(InputEventSpy *spy)
{
Q_UNUSED(spy);
}
InputRedirection *InputRedirection::s_self = nullptr;
}
Introduce a KWin internal on-screen-notification service Summary: Recently we noticed that there are multiple areas where KWin needs to inform the user about how to operate. Examples are: * Screenshot * ColorPicker * Pointer constraint enabled * Pointer constraint about to be removed * Kill Window For Screenshot and ColorPicker we used an EffectFrame to render it. But this is not an optimal solution as it's lacking many features we would need. We cannot properly use it from within KWin core, we cannot implement features like hide on mouse over, etc. etc. This change introduces an OnScreenNotification which supports: * showing an icon * showing a message * timeout It is Qml styled, so that it can be easily adjusted. This is a big improvement over the EffectFrame solution. The Qml file creates a Plasma Dialog of type OSD. Thus KWin places it like the normal OSD windows and also looks kind of similar. In the case of KWin the focus is more on the message, than an icon, so the icon is placed left of the text. While the OnScreenNotification is supposed to be used like a singleton, it doesn't use the KWin singleton pattern. Instead a small wrapper namespace OSD is introduced which provides a convenient API for KWin internal areas to show/hide the notification. By not using the KWin singleton pattern, the OnScreenNotification does not depend on any other parts of KWin and can be easily unit-tested. A few features are still missing and will be added in further commits: * hide-out on mouse over * optional skip close animation (needed for screenshot) * X11 support (not that important as it's mostly for Wayland features) Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3723
2016-12-18 13:53:50 +03:00
using KWin::OnScreenNotification;
void OnScreenNotificationTest::show()
{
OnScreenNotification notification;
[autotests] Disable QtQuick in OnScreenNotificationTest Unfortunately Qt triggers an ASAN error in it's opengl implementation. As we don't really need the visible output in the test, disable QML. While this is unfortunate, it's better than a false-positive failing test. Output from build.kde.org: 18:15:51 ================================================================= 18:15:51 ==13802==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x614000027640 in thread T0: 18:15:51 object passed to delete has wrong type: 18:15:51 size of the allocated type: 400 bytes; 18:15:51 size of the deallocated type: 16 bytes. 18:15:51 #0 0x7fc1632614b2 in operator delete(void*, unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9a4b2) 18:15:51 #1 0x7fc1624f947d in QOpenGLVersionFunctionsStorage::~QOpenGLVersionFunctionsStorage() opengl/qopenglversionfunctions.cpp:81 18:15:51 #2 0x7fc1621c1315 in QOpenGLContextPrivate::~QOpenGLContextPrivate() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Gui.so.5+0x172315) 18:15:51 #3 0x7fc1621c1365 in QOpenGLContextPrivate::~QOpenGLContextPrivate() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Gui.so.5+0x172365) 18:15:51 #4 0x7fc161701e93 in QScopedPointerDeleter<QObjectData>::cleanup(QObjectData*) (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Core.so.5+0x363e93) 18:15:51 #5 0x7fc1617002c0 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::~QScopedPointer() ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:107 18:15:51 #6 0x7fc1616f4d20 in QObject::~QObject() kernel/qobject.cpp:900 18:15:51 #7 0x7fc1621beabf in QOpenGLContext::~QOpenGLContext() kernel/qopenglcontext.cpp:689 18:15:51 #8 0x7fc1621beaf3 in QOpenGLContext::~QOpenGLContext() kernel/qopenglcontext.cpp:696 18:15:51 #9 0x7fc162df817d in QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow*) scenegraph/qsgrenderloop.cpp:323 18:15:51 #10 0x7fc162e3ed8f in QQuickWindow::~QQuickWindow() items/qquickwindow.cpp:1237 18:15:51 #11 0x7fc151a105c1 in PlasmaQuick::Dialog::~Dialog() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/libKF5PlasmaQuick.so.5+0x1235c1) 18:15:51 #12 0x7fc151f4bce4 in QQmlPrivate::QQmlElement<PlasmaQuick::Dialog>::~QQmlElement() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/qml/org/kde/plasma/core/libcorebindingsplugin.so+0x162ce4) 18:15:51 #13 0x7fc151f4bd6d in QQmlPrivate::QQmlElement<PlasmaQuick::Dialog>::~QQmlElement() (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/qml/org/kde/plasma/core/libcorebindingsplugin.so+0x162d6d) 18:15:51 #14 0x41f82f in QScopedPointerDeleter<QObject>::cleanup(QObject*) /srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/include/QtCore/qscopedpointer.h:60 18:15:51 #15 0x41e7a1 in QScopedPointer<QObject, QScopedPointerDeleter<QObject> >::~QScopedPointer() /srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/include/QtCore/qscopedpointer.h:107 18:15:51 #16 0x41c6b0 in KWin::OnScreenNotification::~OnScreenNotification() /home/jenkins/sources/kwin/kf5-qt5/onscreennotification.cpp:55 18:15:51 #17 0x410349 in OnScreenNotificationTest::show() /home/jenkins/sources/kwin/kf5-qt5/autotests/onscreennotificationtest.cpp:42 18:15:51 #18 0x42095f in OnScreenNotificationTest::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) /home/jenkins/sources/kwin/kf5-qt5/build/autotests/moc_onscreennotificationtest.cpp:80 18:15:51 #19 0x7fc1616c3bda in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const kernel/qmetaobject.cpp:2222 18:15:51 #20 0x7fc1642f776c in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Test.so.5+0x1c76c) 18:15:51 #21 0x7fc1642f0820 in QTest::TestMethods::invokeTestOnData(int) const /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:800 18:15:51 #22 0x7fc1642f1353 in QTest::TestMethods::invokeTest(int, char const*, QTest::WatchDog*) const /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:981 18:15:51 #23 0x7fc1642f25d6 in QTest::TestMethods::invokeTests(QObject*) const /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:1314 18:15:51 #24 0x7fc1642f31f7 in QTest::qExec(QObject*, int, char**) /home/jenkins/sources/qt5/kf5-qt5/qtbase/src/testlib/qtestcase.cpp:1724 18:15:51 #25 0x40f5e4 in main /home/jenkins/sources/kwin/kf5-qt5/autotests/onscreennotificationtest.cpp:31 18:15:51 #26 0x7fc160a5babf in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20abf) 18:15:51 #27 0x40d118 in _start (/home/jenkins/sources/kwin/kf5-qt5/build/autotests/testOnScreenNotification+0x40d118) 18:15:51 18:15:51 0x614000027640 is located 0 bytes inside of 400-byte region [0x614000027640,0x6140000277d0) 18:15:51 allocated by thread T0 here: 18:15:51 #0 0x7fc1632608b2 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x998b2) 18:15:51 #1 0x7fc1624f9563 in QOpenGLVersionFunctionsStorage::backend(QOpenGLContext*, QOpenGLVersionFunctionsBackend::Version) opengl/qopenglversionfunctions.cpp:108 18:15:51 #2 0x7fc1624f9b10 in QAbstractOpenGLFunctionsPrivate::functionsBackend(QOpenGLContext*, QOpenGLVersionFunctionsBackend::Version) opengl/qopenglversionfunctions.cpp:122 18:15:51 #3 0x7fc16251475d in QOpenGLFunctions_1_0::initializeOpenGLFunctions() opengl/qopenglfunctions_1_0.cpp:100 18:15:51 #4 0x7fc1621bee83 in QOpenGLContext::versionFunctions(QOpenGLVersionProfile const&) const kernel/qopenglcontext.cpp:862 18:15:51 #5 0x7fc1621c1dbe in QOpenGLFunctions_1_0* QOpenGLContext::versionFunctions<QOpenGLFunctions_1_0>() const (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/qt5/inst/usr/lib/libQt5Gui.so.5+0x172dbe) 18:15:51 #6 0x7fc1621be166 in QOpenGLContextPrivate::maxTextureSize() kernel/qopenglcontext.cpp:382 18:15:51 #7 0x7fc1624df66a in QOpenGLTextureGlyphCache::maxTextureHeight() const opengl/qopengltextureglyphcache.cpp:459 18:15:51 #8 0x7fc162467acf in QTextureGlyphCache::populate(QFontEngine*, int, unsigned int const*, QFixedPoint const*) painting/qtextureglyphcache.cpp:208 18:15:51 #9 0x7fc162dddcfa in QSGTextMaskMaterial::populate(QPointF const&, QVector<unsigned int> const&, QVector<QPointF> const&, QSGGeometry*, QRectF*, QPointF*, QMargins const&) scenegraph/qsgdefaultglyphnode_p.cpp:456 18:15:51 #10 0x7fc162ddbc2b in QSGDefaultGlyphNode::update() scenegraph/qsgdefaultglyphnode.cpp:127 18:15:51 #11 0x7fc162ea3fb9 in QQuickTextNode::addGlyphs(QPointF const&, QGlyphRun const&, QColor const&, QQuickText::TextStyle, QColor const&, QSGNode*) items/qquicktextnode.cpp:115 18:15:51 #12 0x7fc162eaa7f6 in QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode*, QQuickText::TextStyle, QColor const&) items/qquicktextnodeengine.cpp:777 18:15:51 #13 0x7fc162ea4baa in QQuickTextNode::addTextLayout(QPointF const&, QTextLayout*, QColor const&, QQuickText::TextStyle, QColor const&, QColor const&, QColor const&, QColor const&, int, int, int, int) items/qquicktextnode.cpp:265 18:15:51 #14 0x7fc162ea02f9 in QQuickText::updatePaintNode(QSGNode*, QQuickItem::UpdatePaintNodeData*) items/qquicktext.cpp:2304 18:15:51 #15 0x7fc162e48a5f in QQuickWindowPrivate::updateDirtyNode(QQuickItem*) items/qquickwindow.cpp:3104 18:15:51 #16 0x7fc162e476a5 in QQuickWindowPrivate::updateDirtyNodes() items/qquickwindow.cpp:2849 18:15:51 #17 0x7fc162e3a8d2 in QQuickWindowPrivate::syncSceneGraph() items/qquickwindow.cpp:419 18:15:51 #18 0x7fc162df86bc in QSGGuiThreadRenderLoop::renderWindow(QQuickWindow*) scenegraph/qsgrenderloop.cpp:391 18:15:51 #19 0x7fc162df8c95 in QSGGuiThreadRenderLoop::exposureChanged(QQuickWindow*) scenegraph/qsgrenderloop.cpp:442 18:15:51 #20 0x7fc162e39e45 in QQuickWindow::exposeEvent(QExposeEvent*) items/qquickwindow.cpp:216 18:15:51 #21 0x7fc16217600d in QWindow::event(QEvent*) kernel/qwindow.cpp:2105 18:15:51 #22 0x7fc162e3f69e in QQuickWindow::event(QEvent*) items/qquickwindow.cpp:1537 18:15:51 #23 0x7fc151a17911 in PlasmaQuick::Dialog::event(QEvent*) (/srv/jenkins/install/ubuntu/x86_64/g++/kf5-qt5/frameworks/plasma-framework/inst/usr/lib/x86_64-linux-gnu/libKF5PlasmaQuick.so.5+0x12a911) 18:15:51 #24 0x7fc1616b69a7 in QCoreApplicationPrivate::notify_helper(QObject*, QEvent*) kernel/qcoreapplication.cpp:1122 18:15:51 #25 0x7fc1616b65d1 in doNotify kernel/qcoreapplication.cpp:1063 18:15:51 #26 0x7fc1616b6535 in QCoreApplication::notify(QObject*, QEvent*) kernel/qcoreapplication.cpp:1049 18:15:51 #27 0x7fc1621623ef in QGuiApplication::notify(QObject*, QEvent*) kernel/qguiapplication.cpp:1648 18:15:51 #28 0x7fc1616b64b2 in QCoreApplication::notifyInternal2(QObject*, QEvent*) kernel/qcoreapplication.cpp:988 18:15:51 #29 0x7fc16216ac69 in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:234 18:15:51 18:15:51 SUMMARY: AddressSanitizer: new-delete-type-mismatch ??:0 operator delete(void*, unsigned long) 18:15:51 ==13802==HINT: if you don't care about these warnings you may set ASAN_OPTIONS=new_delete_type_mismatch=0 18:15:51 ==13802==ABORTING
2016-12-22 21:25:12 +03:00
auto config = KSharedConfig::openConfig(QString(), KSharedConfig::SimpleConfig);
KConfigGroup group = config->group("OnScreenNotification");
group.writeEntry(QStringLiteral("QmlPath"), QString("/does/not/exist.qml"));
group.sync();
notification.setConfig(config);
Introduce a KWin internal on-screen-notification service Summary: Recently we noticed that there are multiple areas where KWin needs to inform the user about how to operate. Examples are: * Screenshot * ColorPicker * Pointer constraint enabled * Pointer constraint about to be removed * Kill Window For Screenshot and ColorPicker we used an EffectFrame to render it. But this is not an optimal solution as it's lacking many features we would need. We cannot properly use it from within KWin core, we cannot implement features like hide on mouse over, etc. etc. This change introduces an OnScreenNotification which supports: * showing an icon * showing a message * timeout It is Qml styled, so that it can be easily adjusted. This is a big improvement over the EffectFrame solution. The Qml file creates a Plasma Dialog of type OSD. Thus KWin places it like the normal OSD windows and also looks kind of similar. In the case of KWin the focus is more on the message, than an icon, so the icon is placed left of the text. While the OnScreenNotification is supposed to be used like a singleton, it doesn't use the KWin singleton pattern. Instead a small wrapper namespace OSD is introduced which provides a convenient API for KWin internal areas to show/hide the notification. By not using the KWin singleton pattern, the OnScreenNotification does not depend on any other parts of KWin and can be easily unit-tested. A few features are still missing and will be added in further commits: * hide-out on mouse over * optional skip close animation (needed for screenshot) * X11 support (not that important as it's mostly for Wayland features) Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3723
2016-12-18 13:53:50 +03:00
notification.setEngine(new QQmlEngine(&notification));
notification.setMessage(QStringLiteral("Some text so that we see it in the test"));
QSignalSpy visibleChangedSpy(&notification, &OnScreenNotification::visibleChanged);
QCOMPARE(notification.isVisible(), false);
notification.setVisible(true);
QCOMPARE(notification.isVisible(), true);
QCOMPARE(visibleChangedSpy.count(), 1);
// show again should not trigger
notification.setVisible(true);
QCOMPARE(visibleChangedSpy.count(), 1);
// timer should not have hidden
QTest::qWait(500);
QCOMPARE(notification.isVisible(), true);
// hide again
notification.setVisible(false);
QCOMPARE(notification.isVisible(), false);
QCOMPARE(visibleChangedSpy.count(), 2);
// now show with timer
notification.setTimeout(250);
notification.setVisible(true);
QCOMPARE(notification.isVisible(), true);
QCOMPARE(visibleChangedSpy.count(), 3);
QVERIFY(visibleChangedSpy.wait());
QCOMPARE(notification.isVisible(), false);
QCOMPARE(visibleChangedSpy.count(), 4);
}
void OnScreenNotificationTest::timeout()
{
OnScreenNotification notification;
QSignalSpy timeoutChangedSpy(&notification, &OnScreenNotification::timeoutChanged);
QCOMPARE(notification.timeout(), 0);
notification.setTimeout(1000);
QCOMPARE(notification.timeout(), 1000);
QCOMPARE(timeoutChangedSpy.count(), 1);
notification.setTimeout(1000);
QCOMPARE(timeoutChangedSpy.count(), 1);
notification.setTimeout(0);
QCOMPARE(notification.timeout(), 0);
QCOMPARE(timeoutChangedSpy.count(), 2);
}
void OnScreenNotificationTest::iconName()
{
OnScreenNotification notification;
QSignalSpy iconNameChangedSpy(&notification, &OnScreenNotification::iconNameChanged);
QVERIFY(iconNameChangedSpy.isValid());
QCOMPARE(notification.iconName(), QString());
notification.setIconName(QStringLiteral("foo"));
QCOMPARE(notification.iconName(), QStringLiteral("foo"));
QCOMPARE(iconNameChangedSpy.count(), 1);
notification.setIconName(QStringLiteral("foo"));
QCOMPARE(iconNameChangedSpy.count(), 1);
notification.setIconName(QStringLiteral("bar"));
QCOMPARE(notification.iconName(), QStringLiteral("bar"));
QCOMPARE(iconNameChangedSpy.count(), 2);
}
void OnScreenNotificationTest::message()
{
OnScreenNotification notification;
QSignalSpy messageChangedSpy(&notification, &OnScreenNotification::messageChanged);
QVERIFY(messageChangedSpy.isValid());
QCOMPARE(notification.message(), QString());
notification.setMessage(QStringLiteral("foo"));
QCOMPARE(notification.message(), QStringLiteral("foo"));
QCOMPARE(messageChangedSpy.count(), 1);
notification.setMessage(QStringLiteral("foo"));
QCOMPARE(messageChangedSpy.count(), 1);
notification.setMessage(QStringLiteral("bar"));
QCOMPARE(notification.message(), QStringLiteral("bar"));
QCOMPARE(messageChangedSpy.count(), 2);
}