File indexing completed on 2024-05-26 05:33:29

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2007 Lubos Lunak <l.lunak@kde.org>
0006     SPDX-FileCopyrightText: 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 /*
0012 
0013  Testing of painting a window more than once.
0014 
0015 */
0016 
0017 #pragma once
0018 
0019 #include "effect/effect.h"
0020 
0021 #include <QHash>
0022 
0023 namespace KWin
0024 {
0025 
0026 class ThumbnailAsideEffect
0027     : public Effect
0028 {
0029     Q_OBJECT
0030     Q_PROPERTY(int maxWidth READ configuredMaxWidth)
0031     Q_PROPERTY(int spacing READ configuredSpacing)
0032     Q_PROPERTY(qreal opacity READ configuredOpacity)
0033     Q_PROPERTY(int screen READ configuredScreen)
0034 public:
0035     ThumbnailAsideEffect();
0036     void reconfigure(ReconfigureFlags) override;
0037     void paintScreen(const RenderTarget &renderTarget, const RenderViewport &viewport, int mask, const QRegion &region, Output *screen) override;
0038     void paintWindow(const RenderTarget &renderTarget, const RenderViewport &viewport, EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
0039 
0040     // for properties
0041     int configuredMaxWidth() const
0042     {
0043         return maxwidth;
0044     }
0045     int configuredSpacing() const
0046     {
0047         return spacing;
0048     }
0049     qreal configuredOpacity() const
0050     {
0051         return opacity;
0052     }
0053     int configuredScreen() const
0054     {
0055         return screen;
0056     }
0057     bool isActive() const override;
0058 
0059 private Q_SLOTS:
0060     void toggleCurrentThumbnail();
0061     void slotWindowAdded(KWin::EffectWindow *w);
0062     void slotWindowClosed(KWin::EffectWindow *w);
0063     void slotWindowFrameGeometryChanged(KWin::EffectWindow *w, const QRectF &old);
0064     void slotWindowDamaged(KWin::EffectWindow *w);
0065     void repaintAll();
0066 
0067 private:
0068     void addThumbnail(EffectWindow *w);
0069     void removeThumbnail(EffectWindow *w);
0070     void arrange();
0071     struct Data
0072     {
0073         EffectWindow *window; // the same like the key in the hash (makes code simpler)
0074         int index;
0075         QRect rect;
0076     };
0077     QHash<EffectWindow *, Data> windows;
0078     int maxwidth;
0079     int spacing;
0080     double opacity;
0081     int screen;
0082     QRegion painted;
0083 };
0084 
0085 } // namespace