File indexing completed on 2022-10-04 14:26:21

0001 /*
0002  * Copyright 1999 by Martin R. Jones <mjones@kde.org>
0003  * Copyright 2010 by Stefan Böhmann <kde@hilefoks.org>
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 #ifndef AMOR_H
0020 #define AMOR_H
0021 
0022 #include <ctime>
0023 
0024 #include <QQueue>
0025 
0026 #include <KWindowSystem>
0027 
0028 #include "amoranimation.h"
0029 #include "amortips.h"
0030 #include "amorconfig.h"
0031 #include "amorthememanager.h"
0032 #include "queueitem.h"
0033 
0034 #include <xcb/xcb.h>
0035 
0036 class AmorDialog;
0037 class AmorBubble;
0038 class AmorWidget;
0039 
0040 class QTimer;
0041 class KWindowSystem;
0042 class QMenu;
0043 class KConfigBase;
0044 
0045 
0046 class Amor : public QObject
0047 {
0048     Q_OBJECT
0049 
0050     public:
0051         Amor();
0052         ~Amor();
0053 
0054         void showTip(const QString &tip);
0055         void showMessage(const QString &message, int msec = -1);
0056 
0057         void reset();
0058 
0059     public slots:
0060         void screenSaverStopped();
0061         void screenSaverStarted();
0062         void slotWindowActivate(WId);
0063         void slotWindowRemove(WId);
0064         void slotStackingChanged();
0065         void slotWindowChange(WId, NET::Properties, NET::Properties2);
0066         void slotDesktopChange(int);
0067 
0068     protected slots:
0069         void slotMouseClicked(const QPoint &pos);
0070         void slotTimeout();
0071         void slotCursorTimeout();
0072         void slotConfigure();
0073         void slotConfigChanged();
0074         void slotOffsetChanged(int);
0075         void slotWidgetDragged( const QPoint &delta, bool release );
0076         void restack();
0077         void hideBubble(bool forceDequeue = false);
0078         void screenSaverStatusChanged(bool active);
0079 
0080         void slotBubbleTimeout();
0081 
0082     protected:
0083         enum State { Focus, Blur, Normal, Sleeping, Waking, Destroy };
0084 
0085         bool readConfig();
0086         void showBubble();
0087         void selectAnimation(State state=Normal);
0088 
0089     private:
0090         KWindowSystem *mWin;
0091         xcb_window_t mTargetWin;                 // The window that the animations sits on
0092         QRect mTargetRect;              // The goemetry of the target window
0093         xcb_window_t mNextTarget;                // The window that will become the target
0094         AmorWidget *mAmor;              // The widget displaying the animation
0095         AmorThemeManager mTheme;        // Animations used by current theme
0096         AmorAnimation *mBaseAnim;       // The base animation
0097         AmorAnimation *mCurrAnim;       // The currently running animation
0098         int mPosition;                  // The position of the animation
0099         State mState;                   // The current state of the animation
0100         QTimer *mTimer;                 // Frame timer
0101         QTimer *mCursorTimer;           // Cursor timer
0102         QTimer *mStackTimer;            // Restacking timer
0103         QTimer *mBubbleTimer;           // Bubble tip timer (GP: I didn't create this one, it had no use when I found it)
0104         QMenu *mMenu;                   // Our menu
0105         std::time_t mActiveTime;        // The time an active event occurred
0106         QPoint mCursPos;                // The last recorded position of the pointer
0107         QString mTipText;               // Text to display in a bubble when possible
0108         AmorBubble *mBubble;            // Text bubble
0109         AmorTips mTips;                 // Tips to display in the bubble
0110         bool mInDesktopBottom;          // the animation is not on top of the
0111                                         // title bar, but at the bottom of the desktop
0112         AmorConfig mConfig;             // Configuration parameters
0113         bool mForceHideAmorWidget;
0114         QQueue<QueueItem> mTipsQueue;   // GP: tips queue
0115 };
0116 
0117 
0118 #endif
0119 
0120 // kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on;
0121 // vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: