kwin/src/effects.h

685 lines
23 KiB
C
Raw Normal View History

2020-08-02 22:22:19 +00:00
/*
KWin - the KDE window manager
This file is part of the KDE project.
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>
2020-08-02 22:22:19 +00:00
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_EFFECTSIMPL_H
#define KWIN_EFFECTSIMPL_H
#include "kwineffects.h"
#include "scene.h"
#include <QHash>
#include <Plasma/FrameSvg>
#include <memory>
namespace Plasma {
class Theme;
}
namespace KWaylandServer
{
class Display;
}
class QDBusPendingCallWatcher;
class QDBusServiceWatcher;
namespace KWin
{
class AbstractThumbnailItem;
class DesktopThumbnailItem;
class WindowThumbnailItem;
class AbstractClient;
class Compositor;
class Deleted;
class EffectLoader;
class Group;
class Toplevel;
class Unmanaged;
class WindowPropertyNotifyX11Filter;
class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler
{
Q_OBJECT
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:
EffectsHandlerImpl(Compositor *compositor, Scene *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;
Provide expected presentation time to effects Effects are given the interval between two consecutive frames. The main flaw of this approach is that if the Compositor transitions from the idle state to "active" state, i.e. when there is something to repaint, effects may see a very large interval between the last painted frame and the current. In order to address this issue, the Scene invalidates the timer that is used to measure time between consecutive frames before the Compositor is about to become idle. While this works perfectly fine with Xinerama-style rendering, with per screen rendering, determining whether the compositor is about to idle is rather a tedious task mostly because a single output can't be used for the test. Furthermore, since the Compositor schedules pointless repaints just to ensure that it's idle, it might take several attempts to figure out whether the scene timer must be invalidated if you use (true) per screen rendering. Ideally, all effects should use a timeline helper that is aware of the underlying render loop and its timings. However, this option is off the table because it will involve a lot of work to implement it. Alternative and much simpler option is to pass the expected presentation time to effects rather than time between consecutive frames. This means that effects are responsible for determining how much animation timelines have to be advanced. Typically, an effect would have to store the presentation timestamp provided in either prePaint{Screen,Window} and use it in the subsequent prePaint{Screen,Window} call to estimate the amount of time passed between the next and the last frames. Unfortunately, this is an API incompatible change. However, it shouldn't take a lot of work to port third-party binary effects, which don't use the AnimationEffect class, to the new API. On the bright side, we no longer need to be concerned about the Compositor getting idle. We do still try to determine whether the Compositor is about to idle, primarily, because the OpenGL render backend swaps buffers on present, but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override;
void paintScreen(int mask, const QRegion &region, ScreenPaintData& data) override;
/**
* Special hook to perform a paintScreen but just with the windows on @p desktop.
*/
void paintDesktop(int desktop, int mask, QRegion region, ScreenPaintData& data);
void postPaintScreen() override;
Provide expected presentation time to effects Effects are given the interval between two consecutive frames. The main flaw of this approach is that if the Compositor transitions from the idle state to "active" state, i.e. when there is something to repaint, effects may see a very large interval between the last painted frame and the current. In order to address this issue, the Scene invalidates the timer that is used to measure time between consecutive frames before the Compositor is about to become idle. While this works perfectly fine with Xinerama-style rendering, with per screen rendering, determining whether the compositor is about to idle is rather a tedious task mostly because a single output can't be used for the test. Furthermore, since the Compositor schedules pointless repaints just to ensure that it's idle, it might take several attempts to figure out whether the scene timer must be invalidated if you use (true) per screen rendering. Ideally, all effects should use a timeline helper that is aware of the underlying render loop and its timings. However, this option is off the table because it will involve a lot of work to implement it. Alternative and much simpler option is to pass the expected presentation time to effects rather than time between consecutive frames. This means that effects are responsible for determining how much animation timelines have to be advanced. Typically, an effect would have to store the presentation timestamp provided in either prePaint{Screen,Window} and use it in the subsequent prePaint{Screen,Window} call to estimate the amount of time passed between the next and the last frames. Unfortunately, this is an API incompatible change. However, it shouldn't take a lot of work to port third-party binary effects, which don't use the AnimationEffect class, to the new API. On the bright side, we no longer need to be concerned about the Compositor getting idle. We do still try to determine whether the Compositor is about to idle, primarily, because the OpenGL render backend swaps buffers on present, but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) override;
void paintWindow(EffectWindow* w, int mask, const QRegion &region, WindowPaintData& data) override;
void postPaintWindow(EffectWindow* w) override;
void paintEffectFrame(EffectFrame* frame, const QRegion &region, double opacity, double frameOpacity) override;
2011-01-30 14:34:42 +00:00
Effect *provides(Effect::Feature ef);
2011-01-30 14:34:42 +00:00
void drawWindow(EffectWindow* w, int mask, const QRegion &region, WindowPaintData& data) override;
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, int screen) override;
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
QPoint cursorPos() const override;
bool grabKeyboard(Effect* effect) override;
void ungrabKeyboard() override;
// not performing XGrabPointer
void startMouseInterception(Effect *effect, Qt::CursorShape shape) override;
void stopMouseInterception(Effect *effect) override;
bool isMouseInterception() const;
void registerGlobalShortcut(const QKeySequence &shortcut, QAction *action) override;
void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) override;
void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action) override;
Add support for global touchpad swipe gestures Summary: This change adds global touchpad swipe gestures to the GlobalShortcutsManager and hooks up the swipe gestures as defined at the Plasma Affenfels sprint: * swipe up: Desktop Grid * swipe down: Present Windows * swipe left: previous virtual desktop * swipe right: next virtual desktop The main work is handled by two new classes: SwipeGesture and GestureRecognizer. This is implemented in a way that it can be extended to also recognize touch screen gestures and pinch gestures. The SwipeGesture defines what is required for the gesture to trigger. Currently this includes the minimum and maximum number of fingers participating in the gesture and the direction. The gesture gets registered in the GestureRecognizer. The events for the gesture are fed into the GestureRecognizer. It evaluates which gestures could trigger and tracks them for every update of the gesture. In the process of the gesture tracking the GestureRecognizer emits signals on the Gesture: * started: when the Gesture gets considered for a sequence * cancelled: the Gesture no longer matches the sequence * triggered: the sequence ended and the Gesture still matches The remaining changes are related to hook up the existing shortcut framework with the new touchpad gestures. The GlobalShortcutManager gained support for it, InputRedirection and EffectsHandler offer methods to register a QAction. VirtualDesktopManager, PresentWindows and DesktopGrid are adjusted to support the gesture. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel Tags: #plasma_on_wayland Differential Revision: https://phabricator.kde.org/D5097
2017-03-18 10:00:30 +00:00
void registerTouchpadSwipeShortcut(SwipeDirection direction, QAction *action) override;
void* getProxy(QString name) override;
void startMousePolling() override;
void stopMousePolling() override;
EffectWindow* findWindow(WId id) const override;
EffectWindow* findWindow(KWaylandServer::SurfaceInterface *surf) const override;
Add windowsystem plugin for KWin's qpa Summary: KWindowSystem provides a plugin interface to have platform specific implementations. So far KWin relied on the implementation in KWayland-integration repository. This is something I find unsuited, for the following reasons: * any test in KWin for functionality set through the plugin would fail * it's not clear what's going on where * in worst case some code could deadlock * KWin shouldn't use KWindowSystem and only a small subset is allowed to be used The last point needs some further explanation. KWin internally does not and cannot use KWindowSystem. KWindowSystem (especially KWindowInfo) is exposing information which KWin sets. It's more than weird if KWin asks KWindowSystem for the state of a window it set itself. On X11 it's just slow, on Wayland it can result in roundtrips to KWin itself which is dangerous. But due to using Plasma components we have a few areas where we use KWindowSystem. E.g. a Plasma::Dialog sets a window type, the slide in direction, blur and background contrast. This we want to support and need to support. Other API elements we do not want, like for examples the available windows. KWin internal windows either have direct access to KWin or a scripting interface exposed providing (limited) access - there is just no need to have this in KWindowSystem. To make it more clear what KWin supports as API of KWindowSystem for internal windows this change implements a stripped down version of the kwayland-integration plugin. The main difference is that it does not use KWayland at all, but a QWindow internal side channel. To support this EffectWindow provides an accessor for internalWindow and the three already mentioned effects are adjusted to read from the internal QWindow and it's dynamic properties. This change is a first step for a further refactoring. I plan to split the internal window out of ShellClient into a dedicated class. I think there are nowadays too many special cases. If it moves out there is the question whether we really want to use Wayland for the internal windows or whether this is just historic ballast (after all we used to use qwayland for that in the beginning). As the change could introduce regressions I'm targetting 5.16. Test Plan: new test case for window type, manual testing using Alt+Tab for the effects integration. Sliding popups, blur and contrast worked fine. Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D18228
2019-01-13 16:50:32 +00:00
EffectWindow *findWindow(QWindow *w) const override;
EffectWindow *findWindow(const QUuid &id) const override;
EffectWindowList stackingOrder() const override;
2015-03-28 23:13:41 +00:00
void setElevatedWindow(KWin::EffectWindow* w, bool set) override;
void setTabBoxWindow(EffectWindow*) override;
void setTabBoxDesktop(int) override;
EffectWindowList currentTabBoxWindowList() const override;
void refTabBox() override;
void unrefTabBox() override;
void closeTabBox() override;
QList< int > currentTabBoxDesktopList() const override;
int currentTabBoxDesktop() const override;
EffectWindow* currentTabBoxWindow() const override;
void setActiveFullScreenEffect(Effect* e) override;
Effect* activeFullScreenEffect() const override;
bool hasActiveFullScreenEffect() const override;
void addRepaintFull() override;
void addRepaint(const QRect& r) override;
void addRepaint(const QRegion& r) override;
void addRepaint(int x, int y, int w, int h) override;
int activeScreen() const override;
int numScreens() const override;
int screenNumber(const QPoint& pos) const override;
QRect clientArea(clientAreaOption, int screen, int desktop) const override;
QRect clientArea(clientAreaOption, const EffectWindow* c) const override;
QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const override;
QSize virtualScreenSize() const override;
QRect virtualScreenGeometry() const override;
double animationTimeFactor() const override;
void defineCursor(Qt::CursorShape shape) override;
bool checkInputWindowEvent(QMouseEvent *e);
bool checkInputWindowEvent(QWheelEvent *e);
void checkInputWindowStacking();
2011-01-30 14:34:42 +00:00
void reserveElectricBorder(ElectricBorder border, Effect *effect) override;
void unreserveElectricBorder(ElectricBorder border, Effect *effect) override;
2011-01-30 14:34:42 +00:00
void registerTouchBorder(ElectricBorder border, QAction *action) override;
void unregisterTouchBorder(ElectricBorder border, QAction *action) override;
QPainter* scenePainter() override;
void reconfigure() override;
QByteArray readRootProperty(long atom, long type, int format) const override;
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
bool hasDecorationShadows() const override;
2011-01-30 14:34:42 +00:00
bool decorationsHaveAlpha() const override;
2011-01-30 14:34:42 +00:00
bool decorationSupportsBlurBehind() const override;
2011-01-30 14:34:42 +00:00
EffectFrame* effectFrame(EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment) const override;
2011-01-30 14:34:42 +00:00
QVariant kwinOption(KWinOption kwopt) override;
bool isScreenLocked() const override;
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
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();
void grabbedKeyboardEvent(QKeyEvent* e);
bool hasKeyboardGrab() const;
void desktopResized(const QSize &size);
2011-01-30 14:34:42 +00:00
void reloadEffect(Effect *effect) override;
2011-01-30 14:34:42 +00:00
QStringList loadedEffects() const;
QStringList listOfEffects() const;
void unloadAllEffects();
2011-01-30 14:34:42 +00:00
QList<EffectWindow*> elevatedWindows() const;
QStringList activeEffects() const;
2011-01-30 14:34:42 +00:00
/**
* @returns whether or not any effect is currently active where KWin should not use direct scanout
*/
bool blocksDirectScanout() const;
/**
* @returns Whether we are currently in a desktop rendering process triggered by paintDesktop hook
*/
bool isDesktopRendering() const {
return m_desktopRendering;
}
/**
* @returns the desktop currently being rendered in the paintDesktop hook.
*/
int currentRenderedDesktop() const {
return m_currentRenderedDesktop;
}
KWaylandServer::Display *waylandDisplay() const override;
bool animationsSupported() const override;
PlatformCursorImage cursorImage() const override;
void hideCursor() override;
void showCursor() override;
void startInteractiveWindowSelection(std::function<void(KWin::EffectWindow*)> callback) override;
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override;
void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override;
void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override;
KSharedConfigPtr config() const override;
KSharedConfigPtr inputConfig() const override;
Scene *scene() const {
return m_scene;
}
bool touchDown(qint32 id, const QPointF &pos, quint32 time);
bool touchMotion(qint32 id, const QPointF &pos, quint32 time);
bool touchUp(qint32 id, quint32 time);
void highlightWindows(const QVector<EffectWindow *> &windows);
bool isPropertyTypeRegistered(xcb_atom_t atom) const {
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;
/**
* 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.
*/
Effect *findEffect(const QString &name) const;
[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
void renderEffectQuickView(EffectQuickView *effectQuickView) const override;
SessionState sessionState() const override;
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;
public Q_SLOTS:
void slotCurrentTabAboutToChange(EffectWindow* from, EffectWindow* to);
void slotTabAdded(EffectWindow* from, EffectWindow* to);
void slotTabRemoved(EffectWindow* c, EffectWindow* newActiveWindow);
// slots for D-Bus interface
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);
Q_SCRIPTABLE QList<bool> areEffectsSupported(const QStringList &names);
Q_SCRIPTABLE QString supportInformation(const QString& name) const;
Q_SCRIPTABLE QString debug(const QString& name, const QString& parameter = QString()) const;
protected Q_SLOTS:
void slotClientShown(KWin::Toplevel*);
void slotUnmanagedShown(KWin::Toplevel*);
void slotWindowClosed(KWin::Toplevel *c, KWin::Deleted *d);
void slotClientMaximized(KWin::AbstractClient *c, MaximizeMode maxMode);
2011-03-06 09:30:23 +00:00
void slotOpacityChanged(KWin::Toplevel *t, qreal oldOpacity);
void slotClientModalityChanged();
void slotGeometryShapeChanged(KWin::Toplevel *t, const QRect &old);
void slotFrameGeometryChanged(Toplevel *toplevel, const QRect &oldGeometry);
void slotWindowDamaged(KWin::Toplevel *t, const QRegion& r);
void slotOutputEnabled(AbstractOutput *output);
void slotOutputDisabled(AbstractOutput *output);
2011-01-30 14:34:42 +00:00
protected:
void connectNotify(const QMetaMethod &signal) override;
void disconnectNotify(const QMetaMethod &signal) override;
2011-01-30 14:34:42 +00:00
void effectsChanged();
void setupClientConnections(KWin::AbstractClient *client);
void setupUnmanagedConnections(KWin::Unmanaged *u);
2011-01-30 14:34:42 +00:00
/**
* Default implementation does nothing and returns @c true.
*/
virtual bool doGrabKeyboard();
/**
* Default implementation does nothing.
*/
virtual void doUngrabKeyboard();
/**
* Default implementation sets Effects override cursor on the PointerInputRedirection.
*/
virtual void doStartMouseInterception(Qt::CursorShape shape);
/**
* Default implementation removes the Effects override cursor on the PointerInputRedirection.
*/
virtual void doStopMouseInterception();
/**
* Default implementation does nothing
*/
virtual void doCheckInputWindowStacking();
2011-01-30 14:34:42 +00:00
Effect* keyboard_grab_effect;
Effect* fullscreen_effect;
QList<EffectWindow*> elevated_windows;
QMultiMap< int, EffectPair > effect_order;
QHash< long, int > registered_atoms;
private:
void registerPropertyType(long atom, bool reg);
void destroyEffect(Effect *effect);
typedef QVector< Effect*> EffectsList;
typedef EffectsList::const_iterator EffectsIterator;
EffectsList m_activeEffects;
EffectsIterator m_currentDrawWindowIterator;
EffectsIterator m_currentPaintWindowIterator;
EffectsIterator m_currentPaintEffectFrameIterator;
EffectsIterator m_currentPaintScreenIterator;
typedef QHash< QByteArray, QList< Effect*> > PropertyEffectMap;
PropertyEffectMap m_propertiesForEffects;
QHash<QByteArray, qulonglong> m_managedProperties;
Compositor *m_compositor;
Scene *m_scene;
bool m_desktopRendering;
int m_currentRenderedDesktop;
QList<Effect*> m_grabbedMouseEffects;
EffectLoader *m_effectLoader;
int m_trackingCursorChanges;
std::unique_ptr<WindowPropertyNotifyX11Filter> m_x11WindowPropertyNotify;
QList<EffectScreen *> m_effectScreens;
};
class EffectScreenImpl : public EffectScreen
{
Q_OBJECT
public:
explicit EffectScreenImpl(AbstractOutput *output, QObject *parent = nullptr);
AbstractOutput *platformOutput() const;
QString name() const override;
qreal devicePixelRatio() const override;
QRect geometry() const override;
private:
AbstractOutput *m_platformOutput;
};
2011-12-29 09:31:37 +00:00
class EffectWindowImpl : public EffectWindow
{
Q_OBJECT
2011-01-30 14:34:42 +00:00
public:
explicit EffectWindowImpl(Toplevel *toplevel);
~EffectWindowImpl() override;
2011-01-30 14:34:42 +00:00
void enablePainting(int reason) override;
void disablePainting(int reason) override;
bool isPaintingEnabled() override;
2011-01-30 14:34:42 +00:00
void addRepaint(const QRect &r) override;
void addRepaint(int x, int y, int w, int h) override;
void addRepaintFull() override;
void addLayerRepaint(const QRect &r) override;
void addLayerRepaint(int x, int y, int w, int h) override;
void refWindow() override;
void unrefWindow() override;
2011-01-30 14:34:42 +00:00
const EffectWindowGroup* group() const override;
2011-01-30 14:34:42 +00:00
bool isDeleted() const override;
bool isMinimized() const override;
double opacity() const override;
bool hasAlpha() const override;
QStringList activities() const override;
int desktop() const override;
QVector<uint> desktops() const override;
int x() const override;
int y() const override;
int width() const override;
int height() const override;
QSize basicUnit() const override;
QRect geometry() const override;
QRect frameGeometry() const override;
QRect bufferGeometry() const override;
QRect clientGeometry() const override;
QString caption() const override;
QRect expandedGeometry() const override;
int screen() const override;
QPoint pos() const override;
QSize size() const override;
QRect rect() const override;
bool isMovable() const override;
bool isMovableAcrossScreens() const override;
bool isUserMove() const override;
bool isUserResize() const override;
QRect iconGeometry() const override;
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;
bool isCriticalNotification() const override;
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;
bool isOutline() const override;
bool isLockScreen() const override;
KWaylandServer::SurfaceInterface *surface() const override;
bool isFullScreen() const override;
bool isUnresponsive() const override;
QRect contentsRect() const override;
bool decorationHasAlpha() const override;
QIcon icon() const override;
QString windowClass() const override;
NET::WindowType windowType() const override;
bool isSkipSwitcher() const override;
bool isCurrentTab() const override;
QString windowRole() const override;
bool isManaged() const override;
bool isWaylandClient() const override;
bool isX11Client() const override;
pid_t pid() const override;
qlonglong windowId() const override;
QRect decorationInnerRect() const override;
QByteArray readProperty(long atom, long type, int format) const override;
void deleteProperty(long atom) const override;
2011-01-30 14:34:42 +00:00
EffectWindow* findModal() override;
EffectWindow* transientFor() override;
EffectWindowList mainWindows() const override;
2011-01-30 14:34:42 +00:00
void minimize() override;
void unminimize() override;
void closeWindow() override;
void referencePreviousWindowPixmap() override;
void unreferencePreviousWindowPixmap() override;
Add windowsystem plugin for KWin's qpa Summary: KWindowSystem provides a plugin interface to have platform specific implementations. So far KWin relied on the implementation in KWayland-integration repository. This is something I find unsuited, for the following reasons: * any test in KWin for functionality set through the plugin would fail * it's not clear what's going on where * in worst case some code could deadlock * KWin shouldn't use KWindowSystem and only a small subset is allowed to be used The last point needs some further explanation. KWin internally does not and cannot use KWindowSystem. KWindowSystem (especially KWindowInfo) is exposing information which KWin sets. It's more than weird if KWin asks KWindowSystem for the state of a window it set itself. On X11 it's just slow, on Wayland it can result in roundtrips to KWin itself which is dangerous. But due to using Plasma components we have a few areas where we use KWindowSystem. E.g. a Plasma::Dialog sets a window type, the slide in direction, blur and background contrast. This we want to support and need to support. Other API elements we do not want, like for examples the available windows. KWin internal windows either have direct access to KWin or a scripting interface exposed providing (limited) access - there is just no need to have this in KWindowSystem. To make it more clear what KWin supports as API of KWindowSystem for internal windows this change implements a stripped down version of the kwayland-integration plugin. The main difference is that it does not use KWayland at all, but a QWindow internal side channel. To support this EffectWindow provides an accessor for internalWindow and the three already mentioned effects are adjusted to read from the internal QWindow and it's dynamic properties. This change is a first step for a further refactoring. I plan to split the internal window out of ShellClient into a dedicated class. I think there are nowadays too many special cases. If it moves out there is the question whether we really want to use Wayland for the internal windows or whether this is just historic ballast (after all we used to use qwayland for that in the beginning). As the change could introduce regressions I'm targetting 5.16. Test Plan: new test case for window type, manual testing using Alt+Tab for the effects integration. Sliding popups, blur and contrast worked fine. Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D18228
2019-01-13 16:50:32 +00:00
QWindow *internalWindow() const override;
2011-01-30 14:34:42 +00:00
const Toplevel* window() const;
Toplevel* window();
void setWindow(Toplevel* w); // internal
void setSceneWindow(Scene::Window* w); // internal
const Scene::Window* sceneWindow() const; // internal
Scene::Window* sceneWindow(); // internal
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;
void registerThumbnail(AbstractThumbnailItem *item);
QHash<WindowThumbnailItem*, QPointer<EffectWindowImpl> > const &thumbnails() const {
return m_thumbnails;
}
QList<DesktopThumbnailItem*> const &desktopThumbnails() const {
return m_desktopThumbnails;
}
private Q_SLOTS:
void thumbnailDestroyed(QObject *object);
void thumbnailTargetChanged();
void desktopThumbnailDestroyed(QObject *object);
2011-01-30 14:34:42 +00:00
private:
void insertThumbnail(WindowThumbnailItem *item);
2011-01-30 14:34:42 +00:00
Toplevel* toplevel;
Scene::Window* sw; // This one is used only during paint pass.
QHash<int, QVariant> dataMap;
QHash<WindowThumbnailItem*, QPointer<EffectWindowImpl> > m_thumbnails;
QList<DesktopThumbnailItem*> m_desktopThumbnails;
bool managed = false;
bool waylandClient;
bool x11Client;
};
class EffectWindowGroupImpl
: public EffectWindowGroup
2011-01-30 14:34:42 +00:00
{
public:
explicit EffectWindowGroupImpl(Group* g);
EffectWindowList members() const override;
2011-01-30 14:34:42 +00:00
private:
Group* group;
};
Move SceneXRender into a plugin Summary: First step for loading the compositor Scenes through plugins. The general idea is that we currently needlessly pull in all the Scenes although only one will be used. E.g. on X11 we pull in QPainter, although they are not compatible. On Wayland we pull in XRender although they are not compatible. Furthermore our current Scene creation strategy is not really fault tolerant and can create situations where we don't get a compositor. E.g on fbdev backend the default settings won't work as it does not support OpenGL. Long term I want to tackle those conceptional problems together: we try to load all plugins supported by the current platform till we have a scene which works. Thus on Wayland we don't end up in a situation where we don't have a working compositor because the configuration is bad. To make this possible the switch statement in the Scene needs to go and needs to be replaced by a for loop iterating over all the available scenes on the platform. If we go there it makes sense to replace it directly with a plugin based approach. So this is a change which tackles the problem by first introducing the plugin loading. The xrender based scene (as it's the most simple one) is moved into a plugin. It is first tried to find a scene plugin and only if there is none the existing code is used. Test Plan: Tested all scenes Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D7232
2017-08-10 16:13:42 +00:00
class KWIN_EXPORT EffectFrameImpl
: public QObject, public EffectFrame
2011-01-30 14:34:42 +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
void free() override;
void render(const QRegion &region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) override;
Qt::Alignment alignment() const override;
void setAlignment(Qt::Alignment alignment) override;
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;
EffectFrameStyle style() const override {
2011-01-30 14:34:42 +00:00
return m_style;
};
Plasma::FrameSvg& frame() {
return m_frame;
}
bool isStatic() const {
return m_static;
};
2011-01-30 14:34:42 +00:00
void finalRender(QRegion region, double opacity, double frameOpacity) const;
void setShader(GLShader* shader) override {
2011-01-30 14:34:42 +00:00
m_shader = shader;
}
GLShader* shader() const override {
2011-01-30 14:34:42 +00:00
return m_shader;
}
void setSelection(const QRect& selection) override;
2011-01-30 14:34:42 +00:00
const QRect& selection() const {
return m_selectionGeometry;
}
Plasma::FrameSvg& selectionFrame() {
return m_selection;
}
/**
* The foreground text color as specified by the default Plasma theme.
*/
QColor styledTextColor();
2011-01-30 14:34:42 +00:00
private Q_SLOTS:
void plasmaThemeChanged();
private:
Q_DISABLE_COPY(EffectFrameImpl) // As we need to use Qt slots we cannot copy this class
void align(QRect &geometry); // positions geometry around m_point respecting m_alignment
void autoResize(); // Auto-resize if not a static size
EffectFrameStyle m_style;
Plasma::FrameSvg m_frame; // TODO: share between all EffectFrames
Plasma::FrameSvg m_selection;
// Position
bool m_static;
QPoint m_point;
Qt::Alignment m_alignment;
QRect m_geometry;
// Contents
QString m_text;
QFont m_font;
QIcon m_icon;
2011-01-30 14:34:42 +00:00
QSize m_iconSize;
QRect m_selectionGeometry;
Scene::EffectFrame* m_sceneFrame;
GLShader* m_shader;
Plasma::Theme *m_theme;
2011-01-30 14:34:42 +00:00
};
inline
QList<EffectWindow*> EffectsHandlerImpl::elevatedWindows() const
2011-01-30 14:34:42 +00:00
{
if (isScreenLocked())
return QList<EffectWindow*>();
return elevated_windows;
2011-01-30 14:34:42 +00:00
}
inline
xcb_window_t EffectsHandlerImpl::x11RootWindow() const
{
return rootWindow();
}
inline
xcb_connection_t *EffectsHandlerImpl::xcbConnection() const
{
return connection();
}
inline
2011-01-30 14:34:42 +00:00
EffectWindowGroupImpl::EffectWindowGroupImpl(Group* g)
: group(g)
{
}
2011-01-30 14:34:42 +00:00
EffectWindow* effectWindow(Toplevel* w);
EffectWindow* effectWindow(Scene::Window* w);
inline
const Scene::Window* EffectWindowImpl::sceneWindow() const
2011-01-30 14:34:42 +00:00
{
return sw;
2011-01-30 14:34:42 +00:00
}
inline
Scene::Window* EffectWindowImpl::sceneWindow()
2011-01-30 14:34:42 +00:00
{
return sw;
2011-01-30 14:34:42 +00:00
}
inline
const Toplevel* EffectWindowImpl::window() const
2011-01-30 14:34:42 +00:00
{
return toplevel;
2011-01-30 14:34:42 +00:00
}
inline
Toplevel* EffectWindowImpl::window()
2011-01-30 14:34:42 +00:00
{
return toplevel;
2011-01-30 14:34:42 +00:00
}
} // namespace
#endif