Commit graph

11 commits

Author SHA1 Message Date
Laurent Montel
b823747c3b Add explicit moc includes to sources for moc-covered headers
* speeds up incremental builds as changes to a header will not always
  need the full mocs_compilation.cpp for all the target's headers rebuild,
  while having a moc file sourced into a source file only adds minor
  extra costs, due to small own code and the used headers usually
  already covered by the source file, being for the same class/struct
* seems to not slow down clean builds, due to empty mocs_compilation.cpp
  resulting in those quickly processed, while the minor extra cost of the
  sourced moc files does not outweigh that in summary.
  Measured times actually improved by some percent points.
  (ideally CMake would just skip empty mocs_compilation.cpp & its object
  file one day)
* enables compiler to see all methods of a class in same compilation unit
  to do some sanity checks
* potentially more inlining in general, due to more in the compilation unit
* allows to keep using more forward declarations in the header, as with the
  moc code being sourced into the cpp file there definitions can be ensured
  and often are already for the needs of the normal class methods
2023-07-15 08:40:49 +00:00
Vlad Zahorodnii
7fffe99328 build: Add -Wno-unused-parameter compiler option
Due to being a compositor, kwin has to conform to some certain
interfaces. It means a lot of virtual functions and function tables to
integrate with C APIs. Naturally, we not always want to use every
argument in such functions.

Since we get -Wunused-parameter from -Wall, we have to plumb those
unused arguments in order to suppress compiler warnings at the moment.

However, I don't think that extra work is worth it. We cannot change or
alter prototypes in any way to fix the warning the desired way. Q_UNUSED
and similar macros are not good indicators of whether an argument is
used too, we tend to overlook putting or removing those macros. I've
also noticed that Q_UNUSED are not used to guide us with the removal no
longer needed parameters.

Therefore, I think it's worth adding -Wno-unused-parameter compiler
option to stop the compiler producing warnings about unused parameters.
It changes nothing except that we don't need to put Q_UNUSED anymore,
which can be really cumbersome sometimes. Note that it doesn't affect
unused variables, you'll still get a -Wunused-variable compiler warning
if a variable is unused.
2022-10-31 15:50:37 +00:00
Vlad Zahorodnii
6d3f00e82c autotests: Remove QVERIFY(signalSpy.isValid())
We use the PMF syntax so the isValid() check is unnecessary as the
compiler will notify about wrong signal at compile time. It makes
writing autotests feel less boilerplaty.
2022-09-14 09:21:29 +00:00
Vlad Zahorodnii
7096e3ead8 Run clang-format
The .clang-format file is based on the one in ECM except the following
style options:

 - AlwaysBreakBeforeMultilineStrings
 - BinPackArguments
 - BinPackParameters
 - ColumnLimit
 - BreakBeforeBraces
 - KeepEmptyLinesAtTheStartOfBlocks
2022-03-25 13:25:15 +02:00
Vlad Zahorodnii
68c675d00d Make source code more relocatable
Occasionally, I see complaints about the file organization of kwin,
which is fair enough.

This change makes the source code more relocatable by removing relative
paths from includes.

CMAKE_CURRENT_SOURCE_DIR was added to the interface include directories
of kwin library. This means that as long as you link against kwin target,
the real location of the source code of the library doesn't matter.

With autotests, things are not as convenient as with kwin target. Some
tests use cpp files from kwin core. If we move all source code in a src/
directory, they will need to be adjusted, but mostly only in build
scripts.
2021-02-10 15:31:42 +00:00
Aleix Pol
2d1f276c2c Fix warning
Don't include the moc of a file without Q_OBJECT
2020-09-02 13:13:33 +02:00
Vlad Zahorodnii
4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii
1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Martin Gräßlin
80adfd0274 Fade out OnScreenNotification when moving with the mouse over it
Summary:
This change triggers a fade out animation when the mouse is moved over
the OnScreenNotification, thus revealing the windows underneath. When
moving the mouse out of the OnScreenNotification it gets faded in again.

This is useful for various cases, e.g. when picking a color and the pixel
one wants to pick is underneath the notification, or when trying to kill
a window...

Test Plan: Manual testing in nested setup

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3964
2017-01-04 18:04:15 +01:00
Martin Gräßlin
2c3bbb9783 [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 19:25:12 +01:00
Martin Gräßlin
07c6878ff0 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-21 19:43:49 +01:00