2011-11-10 13:28:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_THUMBNAILITEM_H
|
|
|
|
#define KWIN_THUMBNAILITEM_H
|
|
|
|
|
2013-08-08 09:39:39 +00:00
|
|
|
#include <QPointer>
|
2019-01-20 13:04:13 +00:00
|
|
|
#include <QUuid>
|
2013-02-26 08:00:51 +00:00
|
|
|
#include <QWeakPointer>
|
2013-08-08 09:39:39 +00:00
|
|
|
#include <QQuickPaintedItem>
|
2011-11-10 13:28:06 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2015-05-20 14:23:42 +00:00
|
|
|
class AbstractClient;
|
2011-11-10 13:28:06 +00:00
|
|
|
class EffectWindow;
|
|
|
|
class EffectWindowImpl;
|
|
|
|
|
2013-08-08 09:39:39 +00:00
|
|
|
class AbstractThumbnailItem : public QQuickPaintedItem
|
2011-11-10 13:28:06 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2013-03-19 08:08:32 +00:00
|
|
|
Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
|
|
|
|
Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
|
2013-08-08 09:39:39 +00:00
|
|
|
Q_PROPERTY(QQuickItem *clipTo READ clipTo WRITE setClipTo NOTIFY clipToChanged)
|
2011-11-10 13:28:06 +00:00
|
|
|
public:
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~AbstractThumbnailItem() override;
|
2013-03-19 08:08:32 +00:00
|
|
|
qreal brightness() const;
|
|
|
|
qreal saturation() const;
|
2013-08-08 09:39:39 +00:00
|
|
|
QQuickItem *clipTo() const;
|
2013-03-19 08:08:32 +00:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void setBrightness(qreal brightness);
|
|
|
|
void setSaturation(qreal saturation);
|
2013-08-08 09:39:39 +00:00
|
|
|
void setClipTo(QQuickItem *clip);
|
2013-03-19 08:08:32 +00:00
|
|
|
|
2011-11-10 13:28:06 +00:00
|
|
|
Q_SIGNALS:
|
2013-03-19 08:08:32 +00:00
|
|
|
void brightnessChanged();
|
|
|
|
void saturationChanged();
|
2013-08-08 09:39:39 +00:00
|
|
|
void clipToChanged();
|
2012-03-29 13:32:41 +00:00
|
|
|
|
|
|
|
protected:
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
explicit AbstractThumbnailItem(QQuickItem *parent = nullptr);
|
2012-03-29 13:32:41 +00:00
|
|
|
|
2012-03-29 18:17:57 +00:00
|
|
|
protected Q_SLOTS:
|
|
|
|
virtual void repaint(KWin::EffectWindow* w) = 0;
|
|
|
|
|
2011-11-10 13:28:06 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void init();
|
|
|
|
void effectWindowAdded();
|
2013-03-06 08:46:25 +00:00
|
|
|
void compositingToggled();
|
2012-03-29 13:32:41 +00:00
|
|
|
|
2011-11-10 13:28:06 +00:00
|
|
|
private:
|
|
|
|
void findParentEffectWindow();
|
2019-08-10 14:25:02 +00:00
|
|
|
QPointer<EffectWindowImpl> m_parent;
|
2013-03-19 08:08:32 +00:00
|
|
|
qreal m_brightness;
|
|
|
|
qreal m_saturation;
|
2013-08-08 09:39:39 +00:00
|
|
|
QPointer<QQuickItem> m_clipToItem;
|
2011-11-10 13:28:06 +00:00
|
|
|
};
|
|
|
|
|
2012-03-29 13:46:53 +00:00
|
|
|
class WindowThumbnailItem : public AbstractThumbnailItem
|
2012-03-29 13:32:41 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2019-01-20 13:04:13 +00:00
|
|
|
Q_PROPERTY(QUuid wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true)
|
2015-05-20 14:23:42 +00:00
|
|
|
Q_PROPERTY(KWin::AbstractClient *client READ client WRITE setClient NOTIFY clientChanged)
|
2012-03-29 13:32:41 +00:00
|
|
|
public:
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
explicit WindowThumbnailItem(QQuickItem *parent = nullptr);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~WindowThumbnailItem() override;
|
2012-03-29 13:32:41 +00:00
|
|
|
|
2019-01-20 13:04:13 +00:00
|
|
|
QUuid wId() const {
|
2012-03-29 13:32:41 +00:00
|
|
|
return m_wId;
|
|
|
|
}
|
2019-01-20 13:04:13 +00:00
|
|
|
void setWId(const QUuid &wId);
|
2015-05-20 14:23:42 +00:00
|
|
|
AbstractClient *client() const;
|
|
|
|
void setClient(AbstractClient *client);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
void paint(QPainter *painter) override;
|
2012-03-29 13:32:41 +00:00
|
|
|
Q_SIGNALS:
|
2019-01-20 13:04:13 +00:00
|
|
|
void wIdChanged(const QUuid &wid);
|
2012-03-29 13:32:41 +00:00
|
|
|
void clientChanged();
|
2012-03-29 18:17:57 +00:00
|
|
|
protected Q_SLOTS:
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
void repaint(KWin::EffectWindow* w) override;
|
2012-03-29 13:32:41 +00:00
|
|
|
private:
|
2019-01-20 13:04:13 +00:00
|
|
|
QUuid m_wId;
|
2015-05-20 14:23:42 +00:00
|
|
|
AbstractClient *m_client;
|
2012-03-29 13:32:41 +00:00
|
|
|
};
|
|
|
|
|
2012-03-29 18:17:57 +00:00
|
|
|
class DesktopThumbnailItem : public AbstractThumbnailItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged)
|
|
|
|
public:
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
DesktopThumbnailItem(QQuickItem *parent = nullptr);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~DesktopThumbnailItem() override;
|
2012-03-29 18:17:57 +00:00
|
|
|
|
|
|
|
int desktop() const {
|
|
|
|
return m_desktop;
|
|
|
|
}
|
|
|
|
void setDesktop(int desktop);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
void paint(QPainter *painter) override;
|
2012-03-29 18:17:57 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void desktopChanged(int desktop);
|
|
|
|
protected Q_SLOTS:
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
void repaint(KWin::EffectWindow* w) override;
|
2012-03-29 18:17:57 +00:00
|
|
|
private:
|
|
|
|
int m_desktop;
|
|
|
|
};
|
|
|
|
|
2013-03-19 08:08:32 +00:00
|
|
|
inline
|
2012-03-29 13:32:41 +00:00
|
|
|
qreal AbstractThumbnailItem::brightness() const
|
2013-03-19 08:08:32 +00:00
|
|
|
{
|
|
|
|
return m_brightness;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2012-03-29 13:32:41 +00:00
|
|
|
qreal AbstractThumbnailItem::saturation() const
|
2013-03-19 08:08:32 +00:00
|
|
|
{
|
|
|
|
return m_saturation;
|
|
|
|
}
|
|
|
|
|
2013-08-08 09:39:39 +00:00
|
|
|
inline
|
|
|
|
QQuickItem* AbstractThumbnailItem::clipTo() const
|
|
|
|
{
|
|
|
|
return m_clipToItem.data();
|
|
|
|
}
|
|
|
|
|
2013-03-26 13:43:36 +00:00
|
|
|
inline
|
2015-05-20 14:23:42 +00:00
|
|
|
AbstractClient *WindowThumbnailItem::client() const
|
2013-03-26 13:43:36 +00:00
|
|
|
{
|
|
|
|
return m_client;
|
|
|
|
}
|
|
|
|
|
2011-11-10 13:28:06 +00:00
|
|
|
} // KWin
|
|
|
|
|
|
|
|
#endif // KWIN_THUMBNAILITEM_H
|