2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2010, 2011 Martin Gräßlin <mgraesslin@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-12-16 20:08:44 +00:00
|
|
|
#pragma once
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include "kwineffects.h"
|
|
|
|
|
2022-05-09 13:25:49 +00:00
|
|
|
#include "kwinoffscreenquickview.h"
|
2022-12-18 21:56:41 +00:00
|
|
|
#include "scene/workspacescene.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-05-09 13:25:49 +00:00
|
|
|
#include <QFont>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <QHash>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2018-08-31 18:28:22 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2021-08-12 14:08:00 +00:00
|
|
|
class QMouseEvent;
|
|
|
|
class QWheelEvent;
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
namespace KWaylandServer
|
2015-08-31 13:47:01 +00:00
|
|
|
{
|
|
|
|
class Display;
|
|
|
|
}
|
|
|
|
|
2013-01-30 12:07:59 +00:00
|
|
|
class QDBusPendingCallWatcher;
|
|
|
|
class QDBusServiceWatcher;
|
2007-07-06 12:38:41 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
class Window;
|
2012-08-23 16:04:36 +00:00
|
|
|
class Compositor;
|
2011-02-27 09:47:42 +00:00
|
|
|
class Deleted;
|
2014-01-24 14:42:40 +00:00
|
|
|
class EffectLoader;
|
2019-10-31 13:20:42 +00:00
|
|
|
class Group;
|
2011-02-25 21:06:02 +00:00
|
|
|
class Unmanaged;
|
2017-09-16 17:25:33 +00:00
|
|
|
class WindowPropertyNotifyX11Filter;
|
2022-01-19 18:15:31 +00:00
|
|
|
class TabletEvent;
|
|
|
|
class TabletPadId;
|
|
|
|
class TabletToolId;
|
2011-02-25 21:06:02 +00:00
|
|
|
|
2015-11-12 10:29:56 +00:00
|
|
|
class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2011-02-25 19:41:10 +00:00
|
|
|
Q_OBJECT
|
2012-08-30 06:20:26 +00:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Effects")
|
|
|
|
Q_PROPERTY(QStringList activeEffects READ activeEffects)
|
|
|
|
Q_PROPERTY(QStringList loadedEffects READ loadedEffects)
|
|
|
|
Q_PROPERTY(QStringList listOfEffects READ listOfEffects)
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
2022-12-18 21:56:41 +00:00
|
|
|
EffectsHandlerImpl(Compositor *compositor, WorkspaceScene *scene);
|
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
|
|
|
~EffectsHandlerImpl() override;
|
2022-03-23 10:13:38 +00:00
|
|
|
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override;
|
|
|
|
void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
void postPaintScreen() override;
|
2022-03-23 10:13:38 +00:00
|
|
|
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override;
|
|
|
|
void paintWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override;
|
|
|
|
void postPaintWindow(EffectWindow *w) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2012-03-23 01:06:46 +00:00
|
|
|
Effect *provides(Effect::Feature ef);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override;
|
2022-09-07 10:16:36 +00:00
|
|
|
void renderWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void activateWindow(EffectWindow *c) override;
|
|
|
|
EffectWindow *activeWindow() const override;
|
|
|
|
void moveWindow(EffectWindow *w, const QPoint &pos, bool snap = false, double snapAdjust = 1.0) override;
|
|
|
|
void windowToDesktop(EffectWindow *w, int desktop) override;
|
|
|
|
void windowToScreen(EffectWindow *w, EffectScreen *screen) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
void setShowingDesktop(bool showing) override;
|
|
|
|
|
|
|
|
QString currentActivity() const override;
|
|
|
|
int currentDesktop() const override;
|
|
|
|
int numberOfDesktops() const override;
|
|
|
|
void setCurrentDesktop(int desktop) override;
|
|
|
|
void setNumberOfDesktops(int desktops) override;
|
|
|
|
QSize desktopGridSize() const override;
|
|
|
|
int desktopGridWidth() const override;
|
|
|
|
int desktopGridHeight() const override;
|
|
|
|
int workspaceWidth() const override;
|
|
|
|
int workspaceHeight() const override;
|
|
|
|
int desktopAtCoords(QPoint coords) const override;
|
|
|
|
QPoint desktopGridCoords(int id) const override;
|
|
|
|
QPoint desktopCoords(int id) const override;
|
|
|
|
int desktopAbove(int desktop = 0, bool wrap = true) const override;
|
|
|
|
int desktopToRight(int desktop = 0, bool wrap = true) const override;
|
|
|
|
int desktopBelow(int desktop = 0, bool wrap = true) const override;
|
|
|
|
int desktopToLeft(int desktop = 0, bool wrap = true) const override;
|
|
|
|
QString desktopName(int desktop) const override;
|
|
|
|
bool optionRollOverDesktops() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
QPoint cursorPos() const override;
|
2022-03-23 10:13:38 +00:00
|
|
|
bool grabKeyboard(Effect *effect) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
void ungrabKeyboard() override;
|
2013-04-24 14:51:04 +00:00
|
|
|
// not performing XGrabPointer
|
2014-02-27 10:57:59 +00:00
|
|
|
void startMouseInterception(Effect *effect, Qt::CursorShape shape) override;
|
|
|
|
void stopMouseInterception(Effect *effect) override;
|
2016-02-23 11:29:05 +00:00
|
|
|
bool isMouseInterception() const;
|
2013-07-14 20:58:30 +00:00
|
|
|
void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) override;
|
2013-07-15 10:04:13 +00:00
|
|
|
void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action) override;
|
2023-01-25 16:06:32 +00:00
|
|
|
void registerTouchpadSwipeShortcut(SwipeDirection dir, uint fingerCount, QAction *onUp, std::function<void(qreal)> progressCallback) override;
|
|
|
|
void registerTouchpadPinchShortcut(PinchDirection dir, uint fingerCount, QAction *onUp, std::function<void(qreal)> progressCallback) override;
|
2022-09-11 10:14:11 +00:00
|
|
|
void registerTouchscreenSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action, std::function<void(qreal)> progressCallback) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
void startMousePolling() override;
|
|
|
|
void stopMousePolling() override;
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindow *findWindow(WId id) const override;
|
|
|
|
EffectWindow *findWindow(KWaylandServer::SurfaceInterface *surf) const override;
|
2019-01-13 16:50:32 +00:00
|
|
|
EffectWindow *findWindow(QWindow *w) const override;
|
2019-01-20 13:04:13 +00:00
|
|
|
EffectWindow *findWindow(const QUuid &id) const override;
|
2014-02-27 10:57:59 +00:00
|
|
|
EffectWindowList stackingOrder() const override;
|
2022-03-23 10:13:38 +00:00
|
|
|
void setElevatedWindow(KWin::EffectWindow *w, bool set) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void setTabBoxWindow(EffectWindow *) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
void setTabBoxDesktop(int) override;
|
|
|
|
EffectWindowList currentTabBoxWindowList() const override;
|
|
|
|
void refTabBox() override;
|
|
|
|
void unrefTabBox() override;
|
|
|
|
void closeTabBox() override;
|
2022-03-23 10:13:38 +00:00
|
|
|
QList<int> currentTabBoxDesktopList() const override;
|
2014-02-27 10:57:59 +00:00
|
|
|
int currentTabBoxDesktop() const override;
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindow *currentTabBoxWindow() const override;
|
2014-02-27 10:57:59 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void setActiveFullScreenEffect(Effect *e) override;
|
|
|
|
Effect *activeFullScreenEffect() const override;
|
2018-10-03 00:11:59 +00:00
|
|
|
bool hasActiveFullScreenEffect() const override;
|
2014-02-27 10:57:59 +00:00
|
|
|
|
|
|
|
void addRepaintFull() override;
|
2022-03-23 10:13:38 +00:00
|
|
|
void addRepaint(const QRect &r) override;
|
2022-05-16 20:13:39 +00:00
|
|
|
void addRepaint(const QRectF &r) override;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void addRepaint(const QRegion &r) override;
|
2014-02-27 10:57:59 +00:00
|
|
|
void addRepaint(int x, int y, int w, int h) override;
|
2021-10-01 07:23:30 +00:00
|
|
|
EffectScreen *activeScreen() const override;
|
2022-07-28 09:34:33 +00:00
|
|
|
QRectF clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const override;
|
|
|
|
QRectF clientArea(clientAreaOption, const EffectWindow *c) const override;
|
|
|
|
QRectF clientArea(clientAreaOption, const QPoint &p, int desktop) const override;
|
2014-02-27 08:55:45 +00:00
|
|
|
QSize virtualScreenSize() const override;
|
|
|
|
QRect virtualScreenGeometry() const override;
|
2014-02-27 10:57:59 +00:00
|
|
|
double animationTimeFactor() const override;
|
|
|
|
|
|
|
|
void defineCursor(Qt::CursorShape shape) override;
|
2013-06-26 09:40:30 +00:00
|
|
|
bool checkInputWindowEvent(QMouseEvent *e);
|
2016-03-04 13:14:44 +00:00
|
|
|
bool checkInputWindowEvent(QWheelEvent *e);
|
2014-02-27 11:04:15 +00:00
|
|
|
void checkInputWindowStacking();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
void reserveElectricBorder(ElectricBorder border, Effect *effect) override;
|
|
|
|
void unreserveElectricBorder(ElectricBorder border, Effect *effect) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2017-03-31 05:41:21 +00:00
|
|
|
void registerTouchBorder(ElectricBorder border, QAction *action) override;
|
2022-03-09 16:17:37 +00:00
|
|
|
void registerRealtimeTouchBorder(ElectricBorder border, QAction *action, EffectsHandler::TouchBorderCallback progressCallback) override;
|
2017-03-31 05:41:21 +00:00
|
|
|
void unregisterTouchBorder(ElectricBorder border, QAction *action) override;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QPainter *scenePainter() override;
|
2014-02-27 10:57:59 +00:00
|
|
|
void reconfigure() override;
|
|
|
|
QByteArray readRootProperty(long atom, long type, int format) const override;
|
2022-03-23 10:13:38 +00:00
|
|
|
xcb_atom_t announceSupportProperty(const QByteArray &propertyName, Effect *effect) override;
|
|
|
|
void removeSupportProperty(const QByteArray &propertyName, Effect *effect) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
bool hasDecorationShadows() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
bool decorationsHaveAlpha() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-06-21 09:23:31 +00:00
|
|
|
std::unique_ptr<EffectFrame> effectFrame(EffectFrameStyle style, bool staticSize, const QPoint &position, Qt::Alignment alignment) const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
QVariant kwinOption(KWinOption kwopt) override;
|
|
|
|
bool isScreenLocked() const override;
|
2011-04-25 15:04:04 +00:00
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
bool makeOpenGLContextCurrent() override;
|
|
|
|
void doneOpenGLContextCurrent() override;
|
Better handling for making the compositing OpenGL context current
With QtQuick2 it's possible that the scene graph rendering context either
lives in an own thread or uses the main GUI thread. In the latter case
it's the same thread as our compositing OpenGL context lives in. This
means our basic assumption that between two rendering passes the context
stays current does not hold.
The code already ensured that before we start a rendering pass the
context is made current, but there are many more possible cases. If we
use OpenGL in areas not triggered by the rendering loop but in response
to other events the context needs to be made current. This includes the
loading and unloading of effects (some effects use OpenGL in the static
effect check, in the ctor and dtor), background loading of texture data,
lazy loading after first usage invoked by shortcut, etc. etc.
To properly handle these cases new methods are added to EffectsHandler
to make the compositing OpenGL context current. These calls delegate down
into the scene. On non-OpenGL scenes they are noop, but on OpenGL they go
into the backend and make the context current. In addition they ensure
that Qt doesn't think that it's QOpenGLContext is current by calling
doneCurrent() on the QOpenGLContext::currentContext(). This unfortunately
causes an additional call to makeCurrent with a null context, but there
is no other way to tell Qt - it doesn't notice when a different context
is made current with low level API calls. In the multi-threaded
architecture this doesn't matter as ::currentContext() returns null.
A short evaluation showed that a transition to QOpenGLContext doesn't
seem feasible. Qt only supports either GLX or EGL while KWin supports
both and when entering the transition phase for Wayland, it would become
extremely tricky if our native platform is X11, but we want a Wayland
EGL context. A future solution might be to have a "KWin-QPA plugin" which
uses either xcb or Wayland and hides everything from Qt.
The API documentation is extended to describe when the effects-framework
ensures that an OpenGL context is current. The effects are changed to
make the context current in cases where it's not guaranteed. This has
been done by looking for creation or deletion of GLTextures and Shaders.
If there are other OpenGL usages outside the rendering loop, ctor/dtor
this needs to be changed, too.
2013-11-22 14:05:36 +00:00
|
|
|
|
2014-04-16 13:58:06 +00:00
|
|
|
xcb_connection_t *xcbConnection() const override;
|
|
|
|
xcb_window_t x11RootWindow() const override;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
// internal (used by kwin core or compositing code)
|
|
|
|
void startPaint();
|
2022-03-23 10:13:38 +00:00
|
|
|
void grabbedKeyboardEvent(QKeyEvent *e);
|
2011-01-30 14:34:42 +00:00
|
|
|
bool hasKeyboardGrab() const;
|
|
|
|
|
2014-02-27 10:57:59 +00:00
|
|
|
void reloadEffect(Effect *effect) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
QStringList loadedEffects() const;
|
|
|
|
QStringList listOfEffects() const;
|
2015-11-12 10:29:56 +00:00
|
|
|
void unloadAllEffects();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
QList<EffectWindow *> elevatedWindows() const;
|
2011-12-29 22:33:45 +00:00
|
|
|
QStringList activeEffects() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2021-02-02 13:26:43 +00:00
|
|
|
/**
|
|
|
|
* @returns whether or not any effect is currently active where KWin should not use direct scanout
|
|
|
|
*/
|
|
|
|
bool blocksDirectScanout() const;
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
KWaylandServer::Display *waylandDisplay() const override;
|
2015-08-31 13:47:01 +00:00
|
|
|
|
2016-08-10 07:24:53 +00:00
|
|
|
bool animationsSupported() const override;
|
|
|
|
|
2016-10-17 14:12:21 +00:00
|
|
|
PlatformCursorImage cursorImage() const override;
|
|
|
|
|
2016-10-20 08:25:37 +00:00
|
|
|
void hideCursor() override;
|
|
|
|
void showCursor() override;
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void startInteractiveWindowSelection(std::function<void(KWin::EffectWindow *)> callback) override;
|
2016-11-23 14:53:17 +00:00
|
|
|
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override;
|
2016-11-15 14:40:30 +00:00
|
|
|
|
2016-12-23 16:39:12 +00:00
|
|
|
void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override;
|
2017-01-11 19:14:36 +00:00
|
|
|
void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override;
|
2016-12-23 16:39:12 +00:00
|
|
|
|
2016-12-02 19:27:43 +00:00
|
|
|
KSharedConfigPtr config() const override;
|
2017-04-19 15:00:02 +00:00
|
|
|
KSharedConfigPtr inputConfig() const override;
|
2016-12-02 19:27:43 +00:00
|
|
|
|
2022-12-18 21:56:41 +00:00
|
|
|
WorkspaceScene *scene() const
|
2022-03-23 10:13:38 +00:00
|
|
|
{
|
2015-12-03 08:50:40 +00:00
|
|
|
return m_scene;
|
|
|
|
}
|
|
|
|
|
2022-12-21 00:55:20 +00:00
|
|
|
bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time);
|
|
|
|
bool touchMotion(qint32 id, const QPointF &pos, std::chrono::microseconds time);
|
|
|
|
bool touchUp(qint32 id, std::chrono::microseconds time);
|
2016-08-15 13:44:10 +00:00
|
|
|
|
2022-01-19 18:15:31 +00:00
|
|
|
bool tabletToolEvent(KWin::TabletEvent *event);
|
2022-12-21 00:55:20 +00:00
|
|
|
bool tabletToolButtonEvent(uint button, bool pressed, const KWin::TabletToolId &tabletToolId, std::chrono::microseconds time);
|
|
|
|
bool tabletPadButtonEvent(uint button, bool pressed, const KWin::TabletPadId &tabletPadId, std::chrono::microseconds time);
|
|
|
|
bool tabletPadStripEvent(int number, int position, bool isFinger, const KWin::TabletPadId &tabletPadId, std::chrono::microseconds time);
|
|
|
|
bool tabletPadRingEvent(int number, int position, bool isFinger, const KWin::TabletPadId &tabletPadId, std::chrono::microseconds time);
|
2022-01-19 18:15:31 +00:00
|
|
|
|
2016-08-30 13:50:31 +00:00
|
|
|
void highlightWindows(const QVector<EffectWindow *> &windows);
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isPropertyTypeRegistered(xcb_atom_t atom) const
|
|
|
|
{
|
2017-09-16 17:25:33 +00:00
|
|
|
return registered_atoms.contains(atom);
|
|
|
|
}
|
|
|
|
|
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 windowToDesktops(EffectWindow *w, const QVector<uint> &desktops) override;
|
2018-11-13 16:18:46 +00:00
|
|
|
|
2018-12-01 16:23:37 +00:00
|
|
|
/**
|
|
|
|
* Finds an effect with the given name.
|
|
|
|
*
|
|
|
|
* @param name The name of the effect.
|
|
|
|
* @returns The effect with the given name @p name, or nullptr if there
|
|
|
|
* is no such effect loaded.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-12-01 16:23:37 +00:00
|
|
|
Effect *findEffect(const QString &name) const;
|
|
|
|
|
2021-11-19 09:19:59 +00:00
|
|
|
void renderOffscreenQuickView(OffscreenQuickView *effectQuickView) const override;
|
[libkwineffects] Introduce API to easily show a QtQuick scene in an effect
Summary:
EffectQuickView/Scene is a convenient class to render a QtQuick
scenegraph into an effect.
Current methods (such as present windows) involve creating an underlying
platform window which is expensive, causes a headache to filter out
again in the rest of the code, and only works as an overlay.
The new class exposes things more natively to an effect where we don't
mess with real windows, we can perform the painting anywhere in the view
and we don't have issues with hiding/closing.
QtQuick has both software and hardware accelerated modes, and kwin also
has 3 render backends. Every combination is supported.
* When used in OpenGL mode for both, we render into an FBO export the
texture ID then it's up to the effect to render that into a scene.
* When using software QtQuick rendering we blit into an image, upload
that into a KWinGLTexture which serves as an abstraction layer and
render that into the scene.
* When using GL for QtQuick and XRender/QPainter in kwin everything is
rendered into the internal FBO, blit and exported as an image.
* When using software rendering for both an image gets passed directly.
Mouse and keyboard events can be forwarded, only if the effect
intercepts them.
The class is meant to be generic enough that we can remove all the
QtQuick code from Aurorae.
The intention is also to replace EffectFrameImpl using this backend and
we can kill all of the EffectFrame code throughout the scenes.
The close button in present windows will also be ported to this,
simplifiying that code base.
Classes that handle the rendering and handling QML are intentionally
split so that in the future we can have a declarative effects API create
overlays from within the same context. Similar to how one can
instantiate windows from a typical QML scene.
Notes:
I don't like how I pass the kwin GL context from the backends into the
effect, but I need something that works with the library separation. It
also currently has wayland problem if I create a QOpenGLContext before
the QPA is set up with a scene - but I don't have anything better?
I know for the EffectFrame we need an API to push things through the
effects stack to handle blur/invert etc. Will deal with that when we
port the EffectFrame.
Test Plan: Used in an effect
Reviewers: #kwin, zzag
Reviewed By: #kwin, zzag
Subscribers: zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24215
2019-09-27 15:06:37 +00:00
|
|
|
|
2019-11-01 17:14:55 +00:00
|
|
|
SessionState sessionState() const override;
|
2021-03-01 09:45:52 +00:00
|
|
|
QList<EffectScreen *> screens() const override;
|
|
|
|
EffectScreen *screenAt(const QPoint &point) const override;
|
|
|
|
EffectScreen *findScreen(const QString &name) const override;
|
|
|
|
EffectScreen *findScreen(int screenId) const override;
|
2021-07-28 15:14:25 +00:00
|
|
|
void renderScreen(EffectScreen *screen) override;
|
2022-01-19 12:15:03 +00:00
|
|
|
bool isCursorHidden() const override;
|
2022-02-06 12:07:48 +00:00
|
|
|
QRect renderTargetRect() const override;
|
|
|
|
qreal renderTargetScale() const override;
|
2019-11-01 17:14:55 +00:00
|
|
|
|
2022-02-09 13:53:59 +00:00
|
|
|
KWin::EffectWindow *inputPanel() const override;
|
|
|
|
bool isInputPanelOverlay() const override;
|
|
|
|
|
2011-02-28 20:03:13 +00:00
|
|
|
public Q_SLOTS:
|
2022-03-23 10:13:38 +00:00
|
|
|
void slotCurrentTabAboutToChange(EffectWindow *from, EffectWindow *to);
|
|
|
|
void slotTabAdded(EffectWindow *from, EffectWindow *to);
|
|
|
|
void slotTabRemoved(EffectWindow *c, EffectWindow *newActiveWindow);
|
2011-02-28 20:03:13 +00:00
|
|
|
|
2012-08-30 06:20:26 +00:00
|
|
|
// slots for D-Bus interface
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_SCRIPTABLE void reconfigureEffect(const QString &name);
|
|
|
|
Q_SCRIPTABLE bool loadEffect(const QString &name);
|
|
|
|
Q_SCRIPTABLE void toggleEffect(const QString &name);
|
|
|
|
Q_SCRIPTABLE void unloadEffect(const QString &name);
|
|
|
|
Q_SCRIPTABLE bool isEffectLoaded(const QString &name) const;
|
|
|
|
Q_SCRIPTABLE bool isEffectSupported(const QString &name);
|
2014-03-09 08:12:09 +00:00
|
|
|
Q_SCRIPTABLE QList<bool> areEffectsSupported(const QStringList &names);
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_SCRIPTABLE QString supportInformation(const QString &name) const;
|
|
|
|
Q_SCRIPTABLE QString debug(const QString &name, const QString ¶meter = QString()) const;
|
2012-08-30 06:20:26 +00:00
|
|
|
|
2011-02-25 19:41:10 +00:00
|
|
|
protected Q_SLOTS:
|
2022-04-28 07:44:11 +00:00
|
|
|
void slotWindowShown(KWin::Window *);
|
2022-04-22 17:39:12 +00:00
|
|
|
void slotUnmanagedShown(KWin::Window *);
|
2022-04-28 07:44:11 +00:00
|
|
|
void slotWindowClosed(KWin::Window *original, KWin::Deleted *d);
|
|
|
|
void slotClientMaximized(KWin::Window *window, MaximizeMode maxMode);
|
|
|
|
void slotOpacityChanged(KWin::Window *window, qreal oldOpacity);
|
2013-06-19 14:26:55 +00:00
|
|
|
void slotClientModalityChanged();
|
2022-05-16 20:13:39 +00:00
|
|
|
void slotGeometryShapeChanged(KWin::Window *window, const QRectF &old);
|
|
|
|
void slotFrameGeometryChanged(Window *window, const QRectF &oldGeometry);
|
2022-12-14 14:25:29 +00:00
|
|
|
void slotWindowDamaged(KWin::Window *window);
|
2022-07-11 10:41:15 +00:00
|
|
|
void slotOutputAdded(Output *output);
|
|
|
|
void slotOutputRemoved(Output *output);
|
2011-02-25 19:41:10 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
protected:
|
2015-02-07 16:12:53 +00:00
|
|
|
void connectNotify(const QMetaMethod &signal) override;
|
|
|
|
void disconnectNotify(const QMetaMethod &signal) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
void effectsChanged();
|
2022-04-28 07:44:11 +00:00
|
|
|
void setupWindowConnections(KWin::Window *window);
|
2011-03-06 10:13:11 +00:00
|
|
|
void setupUnmanagedConnections(KWin::Unmanaged *u);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2017-09-23 18:21:26 +00:00
|
|
|
/**
|
|
|
|
* Default implementation does nothing and returns @c true.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-23 18:21:26 +00:00
|
|
|
virtual bool doGrabKeyboard();
|
|
|
|
/**
|
|
|
|
* Default implementation does nothing.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-23 18:21:26 +00:00
|
|
|
virtual void doUngrabKeyboard();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default implementation sets Effects override cursor on the PointerInputRedirection.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-23 18:21:26 +00:00
|
|
|
virtual void doStartMouseInterception(Qt::CursorShape shape);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default implementation removes the Effects override cursor on the PointerInputRedirection.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-23 18:21:26 +00:00
|
|
|
virtual void doStopMouseInterception();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default implementation does nothing
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-23 18:21:26 +00:00
|
|
|
virtual void doCheckInputWindowStacking();
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
Effect *keyboard_grab_effect;
|
|
|
|
Effect *fullscreen_effect;
|
|
|
|
QList<EffectWindow *> elevated_windows;
|
|
|
|
QMultiMap<int, EffectPair> effect_order;
|
|
|
|
QHash<long, int> registered_atoms;
|
2011-08-27 09:21:31 +00:00
|
|
|
|
|
|
|
private:
|
2016-11-07 14:57:00 +00:00
|
|
|
void registerPropertyType(long atom, bool reg);
|
2018-12-19 14:44:06 +00:00
|
|
|
void destroyEffect(Effect *effect);
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
typedef QVector<Effect *> EffectsList;
|
2013-07-19 09:34:01 +00:00
|
|
|
typedef EffectsList::const_iterator EffectsIterator;
|
2013-07-19 09:46:42 +00:00
|
|
|
EffectsList m_activeEffects;
|
2013-07-19 09:34:01 +00:00
|
|
|
EffectsIterator m_currentDrawWindowIterator;
|
|
|
|
EffectsIterator m_currentPaintWindowIterator;
|
|
|
|
EffectsIterator m_currentPaintScreenIterator;
|
2022-03-23 10:13:38 +00:00
|
|
|
typedef QHash<QByteArray, QList<Effect *>> PropertyEffectMap;
|
2012-12-13 23:09:47 +00:00
|
|
|
PropertyEffectMap m_propertiesForEffects;
|
|
|
|
QHash<QByteArray, qulonglong> m_managedProperties;
|
2012-08-23 16:04:36 +00:00
|
|
|
Compositor *m_compositor;
|
2022-12-18 21:56:41 +00:00
|
|
|
WorkspaceScene *m_scene;
|
2022-03-23 10:13:38 +00:00
|
|
|
QList<Effect *> m_grabbedMouseEffects;
|
2014-01-24 14:42:40 +00:00
|
|
|
EffectLoader *m_effectLoader;
|
2015-02-07 16:12:53 +00:00
|
|
|
int m_trackingCursorChanges;
|
2017-09-16 17:25:33 +00:00
|
|
|
std::unique_ptr<WindowPropertyNotifyX11Filter> m_x11WindowPropertyNotify;
|
2021-03-01 09:45:52 +00:00
|
|
|
QList<EffectScreen *> m_effectScreens;
|
|
|
|
};
|
|
|
|
|
|
|
|
class EffectScreenImpl : public EffectScreen
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-04-14 12:33:28 +00:00
|
|
|
explicit EffectScreenImpl(Output *output, QObject *parent = nullptr);
|
2021-10-01 07:23:30 +00:00
|
|
|
~EffectScreenImpl() override;
|
2021-03-01 09:45:52 +00:00
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
Output *platformOutput() const;
|
2021-03-01 09:45:52 +00:00
|
|
|
|
|
|
|
QString name() const override;
|
2022-06-29 11:46:05 +00:00
|
|
|
QString manufacturer() const override;
|
|
|
|
QString model() const override;
|
|
|
|
QString serialNumber() const override;
|
2021-03-01 09:45:52 +00:00
|
|
|
qreal devicePixelRatio() const override;
|
|
|
|
QRect geometry() const override;
|
2022-04-04 16:05:56 +00:00
|
|
|
int refreshRate() const override;
|
2021-07-29 02:07:13 +00:00
|
|
|
Transform transform() const override;
|
2021-03-01 09:45:52 +00:00
|
|
|
|
2022-04-14 12:33:28 +00:00
|
|
|
static EffectScreenImpl *get(Output *output);
|
2021-10-01 07:23:30 +00:00
|
|
|
|
2021-03-01 09:45:52 +00:00
|
|
|
private:
|
2022-09-15 20:18:41 +00:00
|
|
|
QPointer<Output> m_platformOutput;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
2011-12-29 09:31:37 +00:00
|
|
|
class EffectWindowImpl : public EffectWindow
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2011-11-10 13:28:06 +00:00
|
|
|
Q_OBJECT
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
2022-04-28 07:44:11 +00:00
|
|
|
explicit EffectWindowImpl(Window *window);
|
2018-11-30 09:58:45 +00:00
|
|
|
~EffectWindowImpl() override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2019-01-07 16:29:00 +00:00
|
|
|
void addRepaint(const QRect &r) override;
|
|
|
|
void addRepaintFull() override;
|
|
|
|
void addLayerRepaint(const QRect &r) override;
|
|
|
|
|
2014-02-27 11:07:41 +00:00
|
|
|
void refWindow() override;
|
|
|
|
void unrefWindow() override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const EffectWindowGroup *group() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2018-11-30 09:58:45 +00:00
|
|
|
bool isDeleted() const override;
|
|
|
|
bool isMinimized() const override;
|
|
|
|
double opacity() const override;
|
|
|
|
|
|
|
|
QStringList activities() const override;
|
|
|
|
QVector<uint> desktops() const override;
|
2022-05-16 20:13:39 +00:00
|
|
|
qreal x() const override;
|
|
|
|
qreal y() const override;
|
|
|
|
qreal width() const override;
|
|
|
|
qreal height() const override;
|
2018-11-30 09:58:45 +00:00
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
QSizeF basicUnit() const override;
|
|
|
|
QRectF frameGeometry() const override;
|
|
|
|
QRectF bufferGeometry() const override;
|
|
|
|
QRectF clientGeometry() const override;
|
2018-11-30 09:58:45 +00:00
|
|
|
|
|
|
|
QString caption() const override;
|
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
QRectF expandedGeometry() const override;
|
2021-10-01 07:23:30 +00:00
|
|
|
EffectScreen *screen() const override;
|
2022-05-16 20:13:39 +00:00
|
|
|
QPointF pos() const override;
|
|
|
|
QSizeF size() const override;
|
|
|
|
QRectF rect() const override;
|
2018-11-30 09:58:45 +00:00
|
|
|
|
|
|
|
bool isMovable() const override;
|
|
|
|
bool isMovableAcrossScreens() const override;
|
|
|
|
bool isUserMove() const override;
|
|
|
|
bool isUserResize() const override;
|
2022-05-16 20:13:39 +00:00
|
|
|
QRectF iconGeometry() const override;
|
2018-11-30 09:58:45 +00:00
|
|
|
|
|
|
|
bool isDesktop() const override;
|
|
|
|
bool isDock() const override;
|
|
|
|
bool isToolbar() const override;
|
|
|
|
bool isMenu() const override;
|
|
|
|
bool isNormalWindow() const override;
|
|
|
|
bool isSpecialWindow() const override;
|
|
|
|
bool isDialog() const override;
|
|
|
|
bool isSplash() const override;
|
|
|
|
bool isUtility() const override;
|
|
|
|
bool isDropdownMenu() const override;
|
|
|
|
bool isPopupMenu() const override;
|
|
|
|
bool isTooltip() const override;
|
|
|
|
bool isNotification() const override;
|
2019-05-02 08:29:38 +00:00
|
|
|
bool isCriticalNotification() const override;
|
2022-05-27 21:49:37 +00:00
|
|
|
bool isAppletPopup() const override;
|
2018-11-30 09:58:45 +00:00
|
|
|
bool isOnScreenDisplay() const override;
|
|
|
|
bool isComboBox() const override;
|
|
|
|
bool isDNDIcon() const override;
|
|
|
|
bool skipsCloseAnimation() const override;
|
|
|
|
|
|
|
|
bool acceptsFocus() const override;
|
|
|
|
bool keepAbove() const override;
|
|
|
|
bool keepBelow() const override;
|
|
|
|
bool isModal() const override;
|
|
|
|
bool isPopupWindow() const override;
|
2019-03-19 14:01:29 +00:00
|
|
|
bool isOutline() const override;
|
2021-05-12 18:56:16 +00:00
|
|
|
bool isLockScreen() const override;
|
2018-11-30 09:58:45 +00:00
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
KWaylandServer::SurfaceInterface *surface() const override;
|
2018-11-30 09:58:45 +00:00
|
|
|
bool isFullScreen() const override;
|
|
|
|
bool isUnresponsive() const override;
|
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
QRectF contentsRect() const override;
|
2018-11-30 09:58:45 +00:00
|
|
|
bool decorationHasAlpha() const override;
|
|
|
|
QIcon icon() const override;
|
|
|
|
QString windowClass() const override;
|
|
|
|
NET::WindowType windowType() const override;
|
|
|
|
bool isSkipSwitcher() const override;
|
|
|
|
QString windowRole() const override;
|
|
|
|
|
|
|
|
bool isManaged() const override;
|
|
|
|
bool isWaylandClient() const override;
|
|
|
|
bool isX11Client() const override;
|
|
|
|
|
2019-09-26 12:54:33 +00:00
|
|
|
pid_t pid() const override;
|
2020-11-01 14:25:15 +00:00
|
|
|
qlonglong windowId() const override;
|
2021-11-22 15:58:04 +00:00
|
|
|
QUuid internalId() const override;
|
2019-09-26 12:54:33 +00:00
|
|
|
|
2022-05-16 20:13:39 +00:00
|
|
|
QRectF decorationInnerRect() const override;
|
2022-02-09 21:00:07 +00:00
|
|
|
KDecoration2::Decoration *decoration() const override;
|
2014-02-27 11:07:41 +00:00
|
|
|
QByteArray readProperty(long atom, long type, int format) const override;
|
|
|
|
void deleteProperty(long atom) const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectWindow *findModal() override;
|
|
|
|
EffectWindow *transientFor() override;
|
2014-02-27 11:07:41 +00:00
|
|
|
EffectWindowList mainWindows() const override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2019-01-07 16:29:00 +00:00
|
|
|
void minimize() override;
|
|
|
|
void unminimize() override;
|
|
|
|
void closeWindow() override;
|
|
|
|
|
2019-01-13 16:50:32 +00:00
|
|
|
QWindow *internalWindow() const override;
|
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
const Window *window() const;
|
|
|
|
Window *window();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
void setWindow(Window *w); // internal
|
2022-05-09 15:47:12 +00:00
|
|
|
void setWindowItem(WindowItem *item); // internal
|
|
|
|
WindowItem *windowItem() const; // internal
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2013-04-24 08:46:34 +00:00
|
|
|
void elevate(bool elevate);
|
|
|
|
|
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 setData(int role, const QVariant &data) override;
|
|
|
|
QVariant data(int role) const override;
|
2011-11-10 13:28:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
2022-05-25 23:13:11 +00:00
|
|
|
void refVisible(const EffectWindowVisibleRef *holder) override;
|
|
|
|
void unrefVisible(const EffectWindowVisibleRef *holder) override;
|
|
|
|
|
2022-04-28 07:44:11 +00:00
|
|
|
Window *m_window;
|
2022-05-09 15:47:12 +00:00
|
|
|
WindowItem *m_windowItem; // This one is used only during paint pass.
|
2011-01-30 14:34:42 +00:00
|
|
|
QHash<int, QVariant> dataMap;
|
2018-11-30 09:58:45 +00:00
|
|
|
bool managed = false;
|
2022-04-28 07:44:11 +00:00
|
|
|
bool m_waylandWindow;
|
|
|
|
bool m_x11Window;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class EffectWindowGroupImpl
|
|
|
|
: public EffectWindowGroup
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-03-23 10:13:38 +00:00
|
|
|
explicit EffectWindowGroupImpl(Group *g);
|
2014-02-27 11:07:41 +00:00
|
|
|
EffectWindowList members() const override;
|
2022-03-23 10:13:38 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
2022-03-23 10:13:38 +00:00
|
|
|
Group *group;
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-05-09 13:25:49 +00:00
|
|
|
class EffectFrameQuickScene : public OffscreenQuickScene
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(QFont font READ font NOTIFY fontChanged)
|
|
|
|
Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
|
|
|
|
Q_PROPERTY(QSize iconSize READ iconSize NOTIFY iconSizeChanged)
|
|
|
|
Q_PROPERTY(QString text READ text NOTIFY textChanged)
|
|
|
|
Q_PROPERTY(qreal frameOpacity READ frameOpacity NOTIFY frameOpacityChanged)
|
|
|
|
Q_PROPERTY(bool crossFadeEnabled READ crossFadeEnabled NOTIFY crossFadeEnabledChanged)
|
|
|
|
Q_PROPERTY(qreal crossFadeProgress READ crossFadeProgress NOTIFY crossFadeProgressChanged)
|
|
|
|
|
|
|
|
public:
|
|
|
|
EffectFrameQuickScene(EffectFrameStyle style, bool staticSize, QPoint position,
|
|
|
|
Qt::Alignment alignment, QObject *parent = nullptr);
|
|
|
|
~EffectFrameQuickScene() override;
|
|
|
|
|
|
|
|
EffectFrameStyle style() const;
|
|
|
|
bool isStatic() const;
|
|
|
|
|
|
|
|
// has to be const-ref to match EffectFrameImpl...
|
|
|
|
const QFont &font() const;
|
|
|
|
void setFont(const QFont &font);
|
|
|
|
Q_SIGNAL void fontChanged(const QFont &font);
|
|
|
|
|
|
|
|
const QIcon &icon() const;
|
|
|
|
void setIcon(const QIcon &icon);
|
|
|
|
Q_SIGNAL void iconChanged(const QIcon &icon);
|
|
|
|
|
|
|
|
const QSize &iconSize() const;
|
|
|
|
void setIconSize(const QSize &iconSize);
|
|
|
|
Q_SIGNAL void iconSizeChanged(const QSize &iconSize);
|
|
|
|
|
|
|
|
const QString &text() const;
|
|
|
|
void setText(const QString &text);
|
|
|
|
Q_SIGNAL void textChanged(const QString &text);
|
|
|
|
|
|
|
|
qreal frameOpacity() const;
|
|
|
|
void setFrameOpacity(qreal frameOpacity);
|
|
|
|
Q_SIGNAL void frameOpacityChanged(qreal frameOpacity);
|
|
|
|
|
|
|
|
bool crossFadeEnabled() const;
|
|
|
|
void setCrossFadeEnabled(bool enabled);
|
|
|
|
Q_SIGNAL void crossFadeEnabledChanged(bool enabled);
|
|
|
|
|
|
|
|
qreal crossFadeProgress() const;
|
|
|
|
void setCrossFadeProgress(qreal progress);
|
|
|
|
Q_SIGNAL void crossFadeProgressChanged(qreal progress);
|
|
|
|
|
|
|
|
Qt::Alignment alignment() const;
|
|
|
|
void setAlignment(Qt::Alignment alignment);
|
|
|
|
|
|
|
|
QPoint position() const;
|
|
|
|
void setPosition(const QPoint &point);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void reposition();
|
|
|
|
|
|
|
|
EffectFrameStyle m_style;
|
|
|
|
|
|
|
|
// Position
|
|
|
|
bool m_static;
|
|
|
|
QPoint m_point;
|
|
|
|
Qt::Alignment m_alignment;
|
|
|
|
|
|
|
|
// Contents
|
|
|
|
QFont m_font;
|
|
|
|
QIcon m_icon;
|
|
|
|
QSize m_iconSize;
|
|
|
|
QString m_text;
|
|
|
|
qreal m_frameOpacity = 0.0;
|
|
|
|
bool m_crossFadeEnabled = false;
|
|
|
|
qreal m_crossFadeProgress = 0.0;
|
|
|
|
};
|
|
|
|
|
2017-08-10 16:13:42 +00:00
|
|
|
class KWIN_EXPORT EffectFrameImpl
|
2022-03-23 10:13:38 +00:00
|
|
|
: public QObject,
|
|
|
|
public EffectFrame
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-07-18 16:32:37 +00:00
|
|
|
Q_OBJECT
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
|
|
|
explicit EffectFrameImpl(EffectFrameStyle style, bool staticSize = true, QPoint position = QPoint(-1, -1),
|
|
|
|
Qt::Alignment alignment = Qt::AlignCenter);
|
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
|
|
|
~EffectFrameImpl() override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-02-27 11:10:18 +00:00
|
|
|
void free() override;
|
2019-10-29 22:04:15 +00:00
|
|
|
void render(const QRegion ®ion = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) override;
|
2014-02-27 11:10:18 +00:00
|
|
|
Qt::Alignment alignment() const override;
|
|
|
|
void setAlignment(Qt::Alignment alignment) override;
|
2022-03-23 10:13:38 +00:00
|
|
|
const QFont &font() const override;
|
|
|
|
void setFont(const QFont &font) override;
|
|
|
|
const QRect &geometry() const override;
|
|
|
|
void setGeometry(const QRect &geometry, bool force = false) override;
|
|
|
|
const QIcon &icon() const override;
|
|
|
|
void setIcon(const QIcon &icon) override;
|
|
|
|
const QSize &iconSize() const override;
|
|
|
|
void setIconSize(const QSize &size) override;
|
|
|
|
void setPosition(const QPoint &point) override;
|
|
|
|
const QString &text() const override;
|
|
|
|
void setText(const QString &text) override;
|
2022-05-09 13:25:49 +00:00
|
|
|
EffectFrameStyle style() const override;
|
|
|
|
bool isCrossFade() const override;
|
|
|
|
void enableCrossFade(bool enable) override;
|
|
|
|
qreal crossFadeProgress() const override;
|
|
|
|
void setCrossFadeProgress(qreal progress) override;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
private:
|
2022-03-23 10:13:38 +00:00
|
|
|
Q_DISABLE_COPY(EffectFrameImpl) // As we need to use Qt slots we cannot copy this class
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2022-05-09 13:25:49 +00:00
|
|
|
EffectFrameQuickScene *m_view;
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect m_geometry;
|
|
|
|
};
|
2007-05-24 14:41:56 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline QList<EffectWindow *> EffectsHandlerImpl::elevatedWindows() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (isScreenLocked()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
return QList<EffectWindow *>();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-05-24 14:41:56 +00:00
|
|
|
return elevated_windows;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-05-24 14:41:56 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline xcb_window_t EffectsHandlerImpl::x11RootWindow() const
|
2014-04-16 13:58:06 +00:00
|
|
|
{
|
2022-02-08 22:28:03 +00:00
|
|
|
return kwinApp()->x11RootWindow();
|
2014-04-16 13:58:06 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline xcb_connection_t *EffectsHandlerImpl::xcbConnection() const
|
2014-04-16 13:58:06 +00:00
|
|
|
{
|
2022-02-08 22:22:38 +00:00
|
|
|
return kwinApp()->x11Connection();
|
2014-04-16 13:58:06 +00:00
|
|
|
}
|
2007-05-24 14:41:56 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline EffectWindowGroupImpl::EffectWindowGroupImpl(Group *g)
|
2011-01-30 14:34:42 +00:00
|
|
|
: group(g)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-05-09 15:47:12 +00:00
|
|
|
inline WindowItem *EffectWindowImpl::windowItem() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-05-09 15:47:12 +00:00
|
|
|
return m_windowItem;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-08-08 14:42:06 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
inline const Window *EffectWindowImpl::window() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-28 07:44:11 +00:00
|
|
|
return m_window;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-08-08 14:42:06 +00:00
|
|
|
|
2022-04-22 17:39:12 +00:00
|
|
|
inline Window *EffectWindowImpl::window()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-04-28 07:44:11 +00:00
|
|
|
return m_window;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-08-08 14:42:06 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|