File indexing completed on 2024-04-21 15:07:54

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 #include <KX11Extras>
0028 
0029 #include "amoranimation.h"
0030 #include "amortips.h"
0031 #include "amorconfig.h"
0032 #include "amorthememanager.h"
0033 #include "queueitem.h"
0034 
0035 #include <xcb/xcb.h>
0036 
0037 class AmorDialog;
0038 class AmorBubble;
0039 class AmorWidget;
0040 
0041 class QTimer;
0042 class KWindowSystem;
0043 class QMenu;
0044 class KConfigBase;
0045 
0046 
0047 class Amor : public QObject
0048 {
0049     Q_OBJECT
0050 
0051     public:
0052         Amor();
0053         ~Amor();
0054 
0055         void showTip(const QString &tip);
0056         void showMessage(const QString &message, int msec = -1);
0057 
0058         void reset();
0059 
0060     public Q_SLOTS:
0061         void screenSaverStopped();
0062         void screenSaverStarted();
0063         void slotWindowActivate(WId);
0064         void slotWindowRemove(WId);
0065         void slotStackingChanged();
0066         void slotWindowChange(WId, NET::Properties, NET::Properties2);
0067         void slotDesktopChange(int desktop);
0068 
0069     protected Q_SLOTS:
0070         void slotMouseClicked(const QPoint &pos);
0071         void slotTimeout();
0072         void slotCursorTimeout();
0073         void slotConfigure();
0074         void slotConfigChanged();
0075         void slotOffsetChanged(int);
0076         void slotWidgetDragged( const QPoint &delta, bool release );
0077         void restack();
0078         void hideBubble(bool forceDequeue = false);
0079         void screenSaverStatusChanged(bool active);
0080 
0081         void slotBubbleTimeout();
0082 
0083     protected:
0084         enum State { Focus, Blur, Normal, Sleeping, Waking, Destroy };
0085 
0086         bool readConfig();
0087         void showBubble();
0088         void selectAnimation(State state=Normal);
0089 
0090     private:
0091         KWindowSystem *mWin;
0092         KX11Extras *mX11Win;
0093         xcb_window_t mTargetWin;                 // The window that the animations sits on
0094         QRect mTargetRect;              // The goemetry of the target window
0095         xcb_window_t mNextTarget;                // The window that will become the target
0096         AmorWidget *mAmor;              // The widget displaying the animation
0097         AmorThemeManager mTheme;        // Animations used by current theme
0098         AmorAnimation *mBaseAnim;       // The base animation
0099         AmorAnimation *mCurrAnim;       // The currently running animation
0100         int mPosition;                  // The position of the animation
0101         State mState;                   // The current state of the animation
0102         QTimer *mTimer;                 // Frame timer
0103         QTimer *mCursorTimer;           // Cursor timer
0104         QTimer *mStackTimer;            // Restacking timer
0105         QTimer *mBubbleTimer;           // Bubble tip timer (GP: I didn't create this one, it had no use when I found it)
0106         QMenu *mMenu;                   // Our menu
0107         std::time_t mActiveTime;        // The time an active event occurred
0108         QPoint mCursPos;                // The last recorded position of the pointer
0109         QString mTipText;               // Text to display in a bubble when possible
0110         AmorBubble *mBubble;            // Text bubble
0111         AmorTips mTips;                 // Tips to display in the bubble
0112         bool mInDesktopBottom;          // the animation is not on top of the
0113                                         // title bar, but at the bottom of the desktop
0114         AmorConfig mConfig;             // Configuration parameters
0115         bool mForceHideAmorWidget;
0116         QQueue<QueueItem> mTipsQueue;   // GP: tips queue
0117 };
0118 
0119 
0120 #endif
0121 
0122 // 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;
0123 // vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: