File indexing completed on 2024-11-10 04:56:59

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2007 Rivo Laks <rivolaks@hot.ee>
0006     SPDX-FileCopyrightText: 2008 Lucas Murray <lmurray@undefinedfire.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #pragma once
0012 
0013 #include "effect/offscreeneffect.h"
0014 
0015 namespace KWin
0016 {
0017 
0018 class GLShader;
0019 
0020 /**
0021  * Inverts desktop's colors
0022  */
0023 class InvertEffect : public OffscreenEffect
0024 {
0025     Q_OBJECT
0026 public:
0027     InvertEffect();
0028     ~InvertEffect() override;
0029 
0030     bool isActive() const override;
0031     bool provides(Feature) override;
0032     int requestedEffectChainPosition() const override;
0033 
0034     static bool supported();
0035 
0036 public Q_SLOTS:
0037     void toggleScreenInversion();
0038     void toggleWindow();
0039 
0040     void slotWindowAdded(KWin::EffectWindow *w);
0041     void slotWindowClosed(KWin::EffectWindow *w);
0042 
0043 protected:
0044     bool loadData();
0045 
0046 private:
0047     bool isInvertable(EffectWindow *window) const;
0048     void invert(EffectWindow *window);
0049     void uninvert(EffectWindow *window);
0050 
0051     bool m_inited;
0052     bool m_valid;
0053     std::unique_ptr<GLShader> m_shader;
0054     bool m_allWindows;
0055     QList<EffectWindow *> m_windows;
0056 };
0057 
0058 inline int InvertEffect::requestedEffectChainPosition() const
0059 {
0060     return 99;
0061 }
0062 
0063 } // namespace