1 | /******************************************************************** |
---|---|
2 | KWin - the KDE window manager |
3 | This file is part of the KDE project. |
4 | |
5 | Copyright (C) 1999, 2000 Daniel M. Duley <mosfet@kde.org> |
6 | Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> |
7 | |
8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | *********************************************************************/ |
21 | |
22 | #include "decorations.h" |
23 | #include "config-kwin.h" |
24 | #include <kdecorationfactory.h> |
25 | |
26 | #include <kglobal.h> |
27 | #include <KDE/KLocalizedString> |
28 | #include <stdlib.h> |
29 | #include <QPixmap> |
30 | |
31 | namespace KWin |
32 | { |
33 | |
34 | KWIN_SINGLETON_FACTORY(DecorationPlugin) |
35 | |
36 | DecorationPlugin::DecorationPlugin(QObject *parent) |
37 | : QObject(parent) |
38 | , KDecorationPlugins(KGlobal::config()) |
39 | , m_disabled(false) |
40 | { |
41 | defaultPlugin = "kwin3_oxygen"; |
42 | #ifndef KWIN_BUILD_OXYGEN |
43 | defaultPlugin = "kwin3_aurorae"; |
44 | #endif |
45 | #ifdef KWIN_BUILD_DECORATIONS |
46 | loadPlugin(""); // load the plugin specified in cfg file |
47 | #else |
48 | setDisabled(true); |
49 | #endif |
50 | } |
51 | |
52 | DecorationPlugin::~DecorationPlugin() |
53 | { |
54 | s_self = NULL; |
55 | } |
56 | |
57 | void DecorationPlugin::error(const QString &error_msg) |
58 | { |
59 | qWarning("%s", QString(i18n( "KWin: ") + error_msg).toLocal8Bit().data()); |
60 | |
61 | setDisabled(true); |
62 | } |
63 | |
64 | bool DecorationPlugin::provides(Requirement) |
65 | { |
66 | return false; |
67 | } |
68 | |
69 | void DecorationPlugin::setDisabled(bool disabled) |
70 | { |
71 | m_disabled = disabled; |
72 | } |
73 | |
74 | bool DecorationPlugin::isDisabled() const |
75 | { |
76 | return m_disabled; |
77 | } |
78 | |
79 | bool DecorationPlugin::hasShadows() const |
80 | { |
81 | if (m_disabled) { |
82 | return false; |
83 | } |
84 | return factory()->supports(AbilityProvidesShadow); |
85 | } |
86 | |
87 | bool DecorationPlugin::hasAlpha() const |
88 | { |
89 | if (m_disabled) { |
90 | return false; |
91 | } |
92 | return factory()->supports(AbilityUsesAlphaChannel); |
93 | } |
94 | |
95 | bool DecorationPlugin::supportsAnnounceAlpha() const |
96 | { |
97 | if (m_disabled) { |
98 | return false; |
99 | } |
100 | return factory()->supports(AbilityAnnounceAlphaChannel); |
101 | } |
102 | |
103 | bool DecorationPlugin::supportsTabbing() const |
104 | { |
105 | if (m_disabled) { |
106 | return false; |
107 | } |
108 | return factory()->supports(AbilityTabbing); |
109 | } |
110 | |
111 | bool DecorationPlugin::supportsFrameOverlap() const |
112 | { |
113 | if (m_disabled) { |
114 | return false; |
115 | } |
116 | return factory()->supports(AbilityExtendIntoClientArea); |
117 | } |
118 | |
119 | bool DecorationPlugin::supportsBlurBehind() const |
120 | { |
121 | if (m_disabled) { |
122 | return false; |
123 | } |
124 | return factory()->supports(AbilityUsesBlurBehind); |
125 | } |
126 | |
127 | Qt::Corner DecorationPlugin::closeButtonCorner() |
128 | { |
129 | if (m_disabled) { |
130 | return Qt::TopRightCorner; |
131 | } |
132 | return factory()->closeButtonCorner(); |
133 | } |
134 | |
135 | QList< int > DecorationPlugin::supportedColors() const |
136 | { |
137 | QList<int> ret; |
138 | if (m_disabled) { |
139 | return ret; |
140 | } |
141 | for (Ability ab = ABILITYCOLOR_FIRST; |
142 | ab < ABILITYCOLOR_END; |
143 | ab = static_cast<Ability>(ab + 1)) |
144 | if (factory()->supports(ab)) |
145 | ret << ab; |
146 | return ret; |
147 | } |
148 | |
149 | void DecorationPlugin::resetCompositing() |
150 | { |
151 | if (m_disabled) { |
152 | return; |
153 | } |
154 | factory()->reset(SettingCompositing); |
155 | } |
156 | |
157 | QString DecorationPlugin::supportInformation() |
158 | { |
159 | if (m_disabled) { |
160 | return "Decoration Plugin disabled\n"; |
161 | } |
162 | QString support; |
163 | support.append("Current Plugin: "); |
164 | support.append(currentPlugin()); |
165 | support.append( |
166 | |
167 | support.append("Shadows: "); |
168 | support.append(hasShadows() ? "yes\n": "no\n"); |
169 | |
170 | support.append("Alpha: "); |
171 | support.append(hasAlpha() ? "yes\n": "no\n"); |
172 | |
173 | support.append("Announces Alpha: "); |
174 | support.append(supportsAnnounceAlpha() ? "yes\n": "no\n"); |
175 | |
176 | support.append("Tabbing: "); |
177 | support.append(supportsTabbing() ? "yes\n": "no\n"); |
178 | |
179 | support.append("Frame Overlap: "); |
180 | support.append(supportsFrameOverlap() ? "yes\n": "no\n"); |
181 | |
182 | support.append("Blur Behind: "); |
183 | support.append(supportsBlurBehind() ? "yes\n": "no\n"); |
184 | // TODO: Qt5 - read support information from Factory |
185 | return support; |
186 | } |
187 | |
188 | } // namespace |
189 |