~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/tabbox.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
 
6
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
 
7
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
 
8
 
 
9
This program is free software; you can redistribute it and/or modify
 
10
it under the terms of the GNU General Public License as published by
 
11
the Free Software Foundation; either version 2 of the License, or
 
12
(at your option) any later version.
 
13
 
 
14
This program is distributed in the hope that it will be useful,
 
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
GNU General Public License for more details.
 
18
 
 
19
You should have received a copy of the GNU General Public License
 
20
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
*********************************************************************/
 
22
 
 
23
#ifndef KWIN_TABBOX_H
 
24
#define KWIN_TABBOX_H
 
25
 
 
26
#include <QTimer>
 
27
#include <QModelIndex>
 
28
#include "utils.h"
 
29
#include "tabbox/tabboxhandler.h"
 
30
 
 
31
class QKeyEvent;
 
32
 
 
33
namespace KWin
 
34
{
 
35
 
 
36
class Workspace;
 
37
class Client;
 
38
namespace TabBox
 
39
{
 
40
class TabBoxConfig;
 
41
 
 
42
class TabBoxHandlerImpl : public TabBoxHandler
 
43
{
 
44
public:
 
45
    TabBoxHandlerImpl();
 
46
    virtual ~TabBoxHandlerImpl();
 
47
 
 
48
    virtual int activeScreen() const;
 
49
    virtual TabBoxClient* activeClient() const;
 
50
    virtual int currentDesktop() const;
 
51
    virtual QString desktopName(TabBoxClient* client) const;
 
52
    virtual QString desktopName(int desktop) const;
 
53
    virtual TabBoxClient* nextClientFocusChain(TabBoxClient* client) const;
 
54
    virtual int nextDesktopFocusChain(int desktop) const;
 
55
    virtual int numberOfDesktops() const;
 
56
    virtual TabBoxClientList stackingOrder() const;
 
57
    virtual void raiseClient(TabBoxClient *client) const;
 
58
    virtual void restack(TabBoxClient *c, TabBoxClient *under);
 
59
    virtual TabBoxClient* clientToAddToList(TabBoxClient* client, int desktop, bool allDesktops) const;
 
60
    virtual TabBoxClient* desktopClient() const;
 
61
    virtual void hideOutline();
 
62
    virtual void showOutline(const QRect &outline);
 
63
    virtual QVector< Window > outlineWindowIds() const;
 
64
};
 
65
 
 
66
class TabBoxClientImpl : public TabBoxClient
 
67
{
 
68
public:
 
69
    TabBoxClientImpl();
 
70
    virtual ~TabBoxClientImpl();
 
71
 
 
72
    virtual QString caption() const;
 
73
    virtual QPixmap icon(const QSize& size = QSize(32, 32)) const;
 
74
    virtual WId window() const;
 
75
    virtual bool isMinimized() const;
 
76
    virtual int x() const;
 
77
    virtual int y() const;
 
78
    virtual int width() const;
 
79
    virtual int height() const;
 
80
 
 
81
    Client* client() const {
 
82
        return m_client;
 
83
    }
 
84
    void setClient(Client* client) {
 
85
        m_client = client;
 
86
    }
 
87
 
 
88
private:
 
89
    Client* m_client;
 
90
};
 
91
 
 
92
class TabBox : public QObject
 
93
{
 
94
    Q_OBJECT
 
95
public:
 
96
    TabBox(Workspace *ws);
 
97
    ~TabBox();
 
98
 
 
99
    Client* currentClient();
 
100
    ClientList currentClientList();
 
101
    int currentDesktop();
 
102
    QList< int > currentDesktopList();
 
103
 
 
104
    void setCurrentClient(Client* newClient);
 
105
    void setCurrentDesktop(int newDesktop);
 
106
 
 
107
    void setMode(TabBoxMode mode);
 
108
    TabBoxMode mode() const {
 
109
        return m_tabBoxMode;
 
110
    }
 
111
 
 
112
    void reset(bool partial_reset = false);
 
113
    void nextPrev(bool next = true);
 
114
 
 
115
    void delayedShow();
 
116
    void hide(bool abort = false);
 
117
 
 
118
    void refDisplay();
 
119
    void unrefDisplay();
 
120
    bool isDisplayed() const;
 
121
 
 
122
    void handleMouseEvent(XEvent*);
 
123
    void grabbedKeyEvent(QKeyEvent* event);
 
124
 
 
125
    Workspace* workspace() const;
 
126
 
 
127
    void reconfigure();
 
128
 
 
129
public slots:
 
130
    void show();
 
131
 
 
132
signals:
 
133
    void tabBoxAdded(int);
 
134
    void tabBoxClosed();
 
135
    void tabBoxUpdated();
 
136
    void tabBoxKeyEvent(QKeyEvent*);
 
137
 
 
138
private:
 
139
    void setCurrentIndex(QModelIndex index, bool notifyEffects = true);
 
140
    void loadConfig(const KConfigGroup& config, TabBoxConfig& tabBoxConfig);
 
141
 
 
142
private:
 
143
    Workspace* wspace;
 
144
    TabBoxMode m_tabBoxMode;
 
145
    QModelIndex m_index;
 
146
    TabBoxHandlerImpl* m_tabBox;
 
147
    bool m_delayShow;
 
148
    int m_delayShowTime;
 
149
 
 
150
    QTimer delayedShowTimer;
 
151
    int display_refcount;
 
152
 
 
153
    TabBoxConfig m_defaultConfig;
 
154
    TabBoxConfig m_alternativeConfig;
 
155
    TabBoxConfig m_desktopConfig;
 
156
    TabBoxConfig m_desktopListConfig;
 
157
    // false if an effect has referenced the tabbox
 
158
    // true if tabbox is active (independent on showTabbox setting)
 
159
    bool m_isShown;
 
160
};
 
161
 
 
162
/*!
 
163
  Returns the tab box' workspace
 
164
 */
 
165
inline Workspace* TabBox::workspace() const
 
166
{
 
167
    return wspace;
 
168
}
 
169
 
 
170
/*!
 
171
  Increase the reference count, preventing the default tabbox from showing.
 
172
 
 
173
  \sa unrefDisplay(), isDisplayed()
 
174
 */
 
175
inline void TabBox::refDisplay()
 
176
{
 
177
    ++display_refcount;
 
178
}
 
179
 
 
180
/*!
 
181
  Returns whether the tab box is being displayed, either natively or by an
 
182
  effect.
 
183
 
 
184
  \sa refDisplay(), unrefDisplay()
 
185
 */
 
186
inline bool TabBox::isDisplayed() const
 
187
{
 
188
    return display_refcount > 0;
 
189
}
 
190
 
 
191
} // namespace TabBox
 
192
 
 
193
} // namespace
 
194
 
 
195
#endif