1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2009 Jorge Mata <matamax123@gmail.com>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*********************************************************************/
21
#include "swiveltabs.h"
27
KWIN_EFFECT(swiveltabs, SwivelTabsEffect)
28
KWIN_EFFECT_SUPPORTED(swiveltabs, SwivelTabsEffect::supported())
30
SwivelTabsEffect::SwivelTabsEffect()
34
reconfigure(ReconfigureAll);
37
bool SwivelTabsEffect::supported()
39
return effects->compositingType() == OpenGLCompositing;
42
void SwivelTabsEffect::reconfigure(ReconfigureFlags)
44
KConfigGroup conf = EffectsHandler::effectConfig("SwivelTabs");
45
vertical = conf.readEntry("SwivelVertical", true);
46
horizontal = conf.readEntry("SwivelHorizontal", true);
47
totalTime = conf.readEntry("SwivelDuration", 500);
50
void SwivelTabsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
53
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
54
effects->prePaintScreen(data, time);
57
void SwivelTabsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
59
if (isActive && (w == windows.show || w == windows.hide)) {
60
data.quads = data.quads.makeGrid(40);
61
data.setTransformed();
62
w->enablePainting(EffectWindow::PAINT_DISABLED);
63
windows.time.addTime(time);
65
effects->prePaintWindow(w, data, time);
68
void SwivelTabsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
70
if (isActive && (w == windows.show || w == windows.hide)) {
71
for (int i = 0; i < data.quads.count(); ++i)
72
transformQuad(data.quads[i]);
74
effects->paintWindow(w, mask, region, data);
77
void SwivelTabsEffect::postPaintWindow(EffectWindow* w)
79
if (isActive && (w == windows.show || w == windows.hide))
81
effects->postPaintWindow(w);
84
void SwivelTabsEffect::transformQuad(WindowQuad &quad)
86
double F = windows.time.progress();
87
int width = quad[1].x() - quad[0].x();
88
int height = quad[3].y() - quad[0].y();
89
int cx = quad[0].x() + (width / 2);
90
int cy = quad[0].y() + (height / 2);
91
if (lastF < 0.5 && F > 0.5) {
92
effects->setElevatedWindow(windows.hide, false);
93
effects->setElevatedWindow(windows.show, true);
98
effects->setElevatedWindow(windows.hide, false);
99
effects->setElevatedWindow(windows.show, false);
103
quad[0].setX(quad[0].x() + (width * F));
104
quad[3].setX(quad[3].x() + (width * F));
105
quad[1].setX(quad[1].x() - (width * F));
106
quad[2].setX(quad[2].x() - (width * F));
109
quad[0].setY(quad[0].y() + (height * F));
110
quad[3].setY(quad[3].y() - (height * F));
111
quad[1].setY(quad[1].y() + (height * F));
112
quad[2].setY(quad[2].y() - (height * F));
117
quad[0].setX(cx - (width * F));
118
quad[3].setX(cx - (width * F));
119
quad[1].setX(cx + (width * F));
120
quad[2].setX(cx + (width * F));
123
quad[0].setY(cy - (height * F));
124
quad[3].setY(cy + (height * F));
125
quad[1].setY(cy - (height * F));
126
quad[2].setY(cy + (height * F));
131
void SwivelTabsEffect::clientGroupItemSwitched(EffectWindow* from, EffectWindow* to)
133
if (isActive || from->isMinimized())
137
windows.time.setCurveShape(TimeLine::LinearCurve);
138
windows.time.setDuration(animationTime(totalTime));
139
windows.time.setProgress(0.0f);
142
effects->setElevatedWindow(to, false);
143
effects->setElevatedWindow(from, true);