File indexing completed on 2024-04-28 05:36:15

0001 /*
0002  *   SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <config-powerdevil.h>
0010 
0011 #include <QAbstractNativeEventFilter>
0012 #include <QObject>
0013 #include <QScopedPointer>
0014 #include <QTimer>
0015 
0016 #if HAVE_XCB
0017 #include <xcb/xcb.h>
0018 #endif
0019 
0020 #include "powerdevilcore_export.h"
0021 
0022 namespace PowerDevil
0023 {
0024 class POWERDEVILCORE_EXPORT KWinKScreenHelperEffect : public QObject, public QAbstractNativeEventFilter
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     explicit KWinKScreenHelperEffect(QObject *parent = nullptr);
0030     ~KWinKScreenHelperEffect() override;
0031 
0032     enum State {
0033         NormalState,
0034         FadingOutState,
0035         FadedOutState,
0036         FadingInState,
0037     };
0038 
0039     bool start();
0040 
0041     bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
0042 
0043 public Q_SLOTS:
0044     void stop();
0045 
0046 Q_SIGNALS:
0047     void stateChanged(State state);
0048     void fadedOut();
0049 
0050 private:
0051     bool checkValid();
0052     void setEffectProperty(long value);
0053 
0054     State m_state = NormalState;
0055     bool m_isValid = false;
0056     bool m_running = false;
0057 
0058     QTimer m_abortTimer;
0059 
0060 #if HAVE_XCB
0061     xcb_atom_t m_atom = 0;
0062 #endif
0063 };
0064 
0065 } // namespace PowerDevil