File: qtcurvehandler.h

package info (click to toggle)
qtcurve 1.9-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,468 kB
  • sloc: cpp: 70,269; perl: 123; sh: 122; xml: 46; makefile: 14
file content (233 lines) | stat: -rw-r--r-- 6,148 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*****************************************************************************
 *   Copyright 2007 - 2010 Craig Drummond <craig.p.drummond@gmail.com>       *
 *   Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com>                     *
 *                                                                           *
 *   This program is free software; you can redistribute it and/or modify    *
 *   it under the terms of the GNU Lesser General Public License as          *
 *   published by the Free Software Foundation; either version 2.1 of the    *
 *   License, or (at your option) version 3, or any later version accepted   *
 *   by the membership of KDE e.V. (or its successor approved by the         *
 *   membership of KDE e.V.), which shall act as a proxy defined in          *
 *   Section 6 of version 3 of the license.                                  *
 *                                                                           *
 *   This program is distributed in the hope that it will be useful,         *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
 *   Lesser General Public License for more details.                         *
 *                                                                           *
 *   You should have received a copy of the GNU Lesser General Public        *
 *   License along with this library. If not,                                *
 *   see <http://www.gnu.org/licenses/>.                                     *
 *****************************************************************************/
/*
  based on the window decoration "Plastik":
  Copyright (C) 2003-2005 Sandro Giessl <sandro@giessl.com>

  based on the window decoration "Web":
  Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
 */

#ifndef KWIN_QTCURVE_H
#define KWIN_QTCURVE_H

#include <QFont>
#include <QApplication>
#include <QBitmap>
#include <kdeversion.h>
#include <kdecoration.h>
#include <kdecorationfactory.h>
#include "config.h"
#include "qtcurveconfig.h"
#include "qtcurveshadowcache.h"

class QStyle;

namespace QtCurve {
namespace KWin {

enum ButtonIcon {
    CloseIcon = 0,
    CloseTabIcon,
    MaxIcon,
    MaxRestoreIcon,
    MinIcon,
    HelpIcon,
    OnAllDesktopsIcon,
    NotOnAllDesktopsIcon,
    KeepAboveIcon,
    NoKeepAboveIcon,
    KeepBelowIcon,
    NoKeepBelowIcon,
    ShadeIcon,
    UnShadeIcon,
    MenuIcon,
    NumButtonIcons
};

class QtCurveClient;
class QtCurveDBus;

#if !KDE_IS_VERSION(4, 11, 0)
// KDecorationFactoryUnstable already does nothing before 4.11 and
// is removed in kde5.
#define _KDecorationFactoryBase KDecorationFactoryUnstable
#else
#define _KDecorationFactoryBase KDecorationFactory
#endif

class QtCurveHandler : public QObject, public _KDecorationFactoryBase {
    Q_OBJECT
public:
    QtCurveHandler();
    ~QtCurveHandler();
    void setStyle();
    bool reset(unsigned long changed) override;
    void setBorderSize();

    KDecoration *createDecoration(KDecorationBridge*) override;
    bool supports(Ability ability) const override;

    const QBitmap &buttonBitmap(ButtonIcon type, const QSize &size,
                                bool toolWindow);
    int
    titleHeight() const
    {
        return m_titleHeight;
    }
    int
    titleHeightTool() const
    {
        return m_titleHeightTool;
    }
    const QFont&
    titleFont()
    {
        return m_titleFont;
    }
    const QFont&
    titleFontTool()
    {
        return m_titleFontTool;
    }
    int borderSize(bool bot=false) const;
    bool
    showResizeGrip() const
    {
        return QtCurveConfig::BORDER_NONE == m_config.borderSize();
    }
    bool
    haveBottomBorder() const
    {
        return QtCurveConfig::BORDER_NONE!=m_config.borderSize();
    }
    bool
    roundBottom() const
    {
        return (m_config.roundBottom() &&
                m_config.borderSize() > QtCurveConfig::BORDER_NONE);
    }
    QtCurveConfig::Shade
    outerBorder() const
    {
        return m_config.outerBorder();
    }
    QtCurveConfig::Shade
    innerBorder() const
    {
        return m_config.innerBorder();
    }
    QStyle*
    wStyle() const
    {
        return m_style ? m_style : QApplication::style();
    }
    int borderEdgeSize() const;
    int
    titleBarPad() const
    {
        return m_config.titleBarPad();
    }
    int
    edgePad() const
    {
        return m_config.edgePad();
    }
    bool
    borderlessMax() const
    {
        return m_config.borderlessMax();
    }
    int
    opacity(bool active) const
    {
        return m_config.opacity(active);
    }
    bool
    opaqueBorder() const
    {
        return m_config.opaqueBorder();
    }
    bool
    customShadows() const
    {
        return m_config.customShadows();
    }
    QtCurveShadowCache&
    shadowCache()
    {
        return m_shadowCache;
    }
    bool
    grouping() const
    {
        return m_config.grouping();
    }
    void menuBarSize(unsigned int xid, int size);
    void statusBarState(unsigned int xid, bool state);
    void emitToggleMenuBar(int xid);
    void emitToggleStatusBar(int xid);
    void borderSizeChanged();
    void
    addClient(QtCurveClient *c)
    {
        m_clients.append(c);
    }
    void removeClient(QtCurveClient *c);
    bool wasLastMenu(unsigned int id)
    {
        return id == m_lastMenuXid;
    }
    bool
    wasLastStatus(unsigned int id)
    {
        return id == m_lastStatusXid;
    }
    const QColor&
    hoverCol(bool active)
    {
        return m_hoverCols[active ? 1 : 0];
    }
private:
    bool readConfig(bool compositingToggled=false);

    int m_borderSize;
    int m_titleHeight;
    int m_titleHeightTool;
    int m_timeStamp;
    unsigned int m_lastMenuXid;
    unsigned int m_lastStatusXid;
    QFont m_titleFont;
    QFont m_titleFontTool;
    QStyle *m_style;
    QBitmap m_bitmaps[2][NumButtonIcons];
    QtCurveConfig m_config;
    QList<QtCurveClient*> m_clients;
    QtCurveDBus *m_dBus;
    QColor m_hoverCols[2];
    QtCurveShadowCache m_shadowCache;
};
QtCurveHandler *Handler();
}
}

#endif