File indexing completed on 2024-04-28 16:55:13
0001 /*************************************************************************** 0002 * Copyright (C) 2015 Kai Uwe Broulik <kde@privat.broulik.de> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the * 0016 * Free Software Foundation, Inc., * 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 0018 ***************************************************************************/ 0019 0020 #ifndef KWINKSCREENHELPEREFFECT_H 0021 #define KWINKSCREENHELPEREFFECT_H 0022 0023 #include <config-powerdevil.h> 0024 0025 #include <QAbstractNativeEventFilter> 0026 #include <QObject> 0027 #include <QScopedPointer> 0028 #include <QTimer> 0029 0030 #if HAVE_XCB 0031 #include <xcb/xcb.h> 0032 #endif 0033 0034 namespace PowerDevil 0035 { 0036 class Q_DECL_EXPORT KWinKScreenHelperEffect : public QObject, public QAbstractNativeEventFilter 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 explicit KWinKScreenHelperEffect(QObject *parent = nullptr); 0042 ~KWinKScreenHelperEffect() override; 0043 0044 enum State { 0045 NormalState, 0046 FadingOutState, 0047 FadedOutState, 0048 FadingInState 0049 }; 0050 0051 bool start(); 0052 0053 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0054 bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; 0055 #else 0056 bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override; 0057 #endif 0058 0059 public Q_SLOTS: 0060 void stop(); 0061 0062 Q_SIGNALS: 0063 void stateChanged(State state); 0064 void fadedOut(); 0065 0066 private: 0067 bool checkValid(); 0068 void setEffectProperty(long value); 0069 0070 State m_state = NormalState; 0071 bool m_isValid = false; 0072 bool m_running = false; 0073 0074 QTimer m_abortTimer; 0075 0076 #if HAVE_XCB 0077 xcb_atom_t m_atom = 0; 0078 #endif 0079 0080 }; 0081 0082 } // namespace PowerDevil 0083 0084 #endif // KWINKSCREENHELPEREFFECT_H