2009-06-19 09:18:07 +00:00
|
|
|
/********************************************************************
|
2010-04-12 19:28:58 +00:00
|
|
|
Copyright (C) 2009, 2010 Martin Gräßlin <kde@martin-graesslin.com>
|
2009-06-19 09:18:07 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
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
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#include "aurorae.h"
|
2010-04-12 19:28:58 +00:00
|
|
|
#include "auroraescene.h"
|
|
|
|
#include "auroraetheme.h"
|
2009-06-19 09:18:07 +00:00
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QGraphicsView>
|
2010-05-09 09:08:09 +00:00
|
|
|
#include <QGraphicsSceneMouseEvent>
|
2009-06-19 09:18:07 +00:00
|
|
|
|
|
|
|
#include <KConfig>
|
|
|
|
#include <KConfigGroup>
|
2010-04-12 19:28:58 +00:00
|
|
|
#include <Plasma/FrameSvg>
|
2009-06-19 09:18:07 +00:00
|
|
|
|
|
|
|
namespace Aurorae
|
|
|
|
{
|
|
|
|
|
|
|
|
AuroraeFactory::AuroraeFactory()
|
|
|
|
: QObject()
|
|
|
|
, KDecorationFactoryUnstable()
|
2010-04-12 19:28:58 +00:00
|
|
|
, m_theme(new AuroraeTheme(this))
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AuroraeFactory::init()
|
|
|
|
{
|
|
|
|
KConfig conf("auroraerc");
|
|
|
|
KConfigGroup group(&conf, "Engine");
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
const QString themeName = group.readEntry("ThemeName", "example-deco");
|
|
|
|
KConfig config("aurorae/themes/" + themeName + '/' + themeName + "rc", KConfig::FullConfig, "data");
|
2010-04-21 18:18:45 +00:00
|
|
|
KConfigGroup themeGroup(&conf, themeName);
|
2010-04-12 19:28:58 +00:00
|
|
|
m_theme->loadTheme(themeName, config);
|
2010-04-21 18:18:45 +00:00
|
|
|
m_theme->setBorderSize((KDecorationDefines::BorderSize)themeGroup.readEntry<int>("BorderSize", KDecorationDefines::BorderNormal));
|
|
|
|
m_theme->setButtonSize((KDecorationDefines::BorderSize)themeGroup.readEntry<int>("ButtonSize", KDecorationDefines::BorderNormal));
|
2010-04-17 17:56:04 +00:00
|
|
|
m_theme->setShowTooltips(options()->showTooltips());
|
2010-05-09 16:34:58 +00:00
|
|
|
m_theme->setTabDragMimeType(clientGroupItemDragMimeType());
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AuroraeFactory::~AuroraeFactory()
|
|
|
|
{
|
|
|
|
s_instance = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuroraeFactory *AuroraeFactory::instance()
|
|
|
|
{
|
|
|
|
if (!s_instance) {
|
|
|
|
s_instance = new AuroraeFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AuroraeFactory::reset(unsigned long changed)
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
resetDecorations(changed);
|
|
|
|
return false; // need hard reset
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AuroraeFactory::supports(Ability ability) const
|
|
|
|
{
|
|
|
|
switch (ability) {
|
|
|
|
case AbilityAnnounceButtons:
|
|
|
|
case AbilityUsesAlphaChannel:
|
|
|
|
case AbilityButtonMenu:
|
|
|
|
case AbilityButtonSpacer:
|
2009-12-16 17:51:58 +00:00
|
|
|
case AbilityExtendIntoClientArea:
|
2009-06-19 09:18:07 +00:00
|
|
|
return true;
|
|
|
|
case AbilityButtonMinimize:
|
2010-04-12 19:28:58 +00:00
|
|
|
return m_theme->hasButton(MinimizeButton);
|
2009-06-19 09:18:07 +00:00
|
|
|
case AbilityButtonMaximize:
|
2010-04-12 19:28:58 +00:00
|
|
|
return m_theme->hasButton(MaximizeButton) || m_theme->hasButton(RestoreButton);
|
2009-06-19 09:18:07 +00:00
|
|
|
case AbilityButtonClose:
|
2010-04-12 19:28:58 +00:00
|
|
|
return m_theme->hasButton(CloseButton);
|
2009-06-19 09:18:07 +00:00
|
|
|
case AbilityButtonAboveOthers:
|
2010-04-12 19:28:58 +00:00
|
|
|
return m_theme->hasButton(KeepAboveButton);
|
2009-06-19 09:18:07 +00:00
|
|
|
case AbilityButtonBelowOthers:
|
2010-04-12 19:28:58 +00:00
|
|
|
return m_theme->hasButton(KeepBelowButton);
|
2009-06-19 09:18:07 +00:00
|
|
|
case AbilityButtonShade:
|
2010-04-12 19:28:58 +00:00
|
|
|
return m_theme->hasButton(ShadeButton);
|
2009-06-19 09:18:07 +00:00
|
|
|
case AbilityButtonOnAllDesktops:
|
2010-04-12 19:28:58 +00:00
|
|
|
return m_theme->hasButton(AllDesktopsButton);
|
2009-06-19 09:18:07 +00:00
|
|
|
case AbilityButtonHelp:
|
2010-04-12 19:28:58 +00:00
|
|
|
return m_theme->hasButton(HelpButton);
|
2009-06-19 09:18:07 +00:00
|
|
|
case AbilityProvidesShadow:
|
2010-04-12 19:28:58 +00:00
|
|
|
return true; // TODO: correct value from theme
|
2010-05-09 09:08:09 +00:00
|
|
|
case AbilityClientGrouping:
|
|
|
|
return true;
|
2010-11-10 18:33:07 +00:00
|
|
|
case AbilityUsesBlurBehind:
|
|
|
|
return true;
|
2009-06-19 09:18:07 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
KDecoration *AuroraeFactory::createDecoration(KDecorationBridge *bridge)
|
|
|
|
{
|
|
|
|
AuroraeClient *client = new AuroraeClient(bridge, this);
|
2010-04-12 19:28:58 +00:00
|
|
|
return client;
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2009-11-08 20:35:34 +00:00
|
|
|
QList< KDecorationDefines::BorderSize > AuroraeFactory::borderSizes() const
|
|
|
|
{
|
|
|
|
return QList< BorderSize >() << BorderTiny << BorderNormal <<
|
|
|
|
BorderLarge << BorderVeryLarge << BorderHuge <<
|
|
|
|
BorderVeryHuge << BorderOversized;
|
|
|
|
}
|
|
|
|
|
2009-06-19 09:18:07 +00:00
|
|
|
|
|
|
|
AuroraeFactory *AuroraeFactory::s_instance = NULL;
|
|
|
|
|
|
|
|
/*******************************************************
|
2010-04-12 19:28:58 +00:00
|
|
|
* Client
|
2009-06-19 09:18:07 +00:00
|
|
|
*******************************************************/
|
2010-04-12 19:28:58 +00:00
|
|
|
AuroraeClient::AuroraeClient(KDecorationBridge *bridge, KDecorationFactory *factory)
|
|
|
|
: KDecorationUnstable(bridge, factory)
|
2010-05-09 09:08:09 +00:00
|
|
|
, m_clickInProgress(false)
|
2010-04-12 19:28:58 +00:00
|
|
|
{
|
|
|
|
m_scene = new AuroraeScene(AuroraeFactory::instance()->theme(),
|
|
|
|
options()->customButtonPositions() ? options()->titleButtonsLeft() : AuroraeFactory::instance()->theme()->defaultButtonsLeft(),
|
|
|
|
options()->customButtonPositions() ? options()->titleButtonsRight() : AuroraeFactory::instance()->theme()->defaultButtonsRight(),
|
2010-06-19 15:23:48 +00:00
|
|
|
providesContextHelp(), NULL);
|
2010-04-12 19:28:58 +00:00
|
|
|
connect(m_scene, SIGNAL(closeWindow()), SLOT(closeWindow()));
|
|
|
|
connect(m_scene, SIGNAL(maximize(Qt::MouseButtons)), SLOT(maximize(Qt::MouseButtons)));
|
|
|
|
connect(m_scene, SIGNAL(showContextHelp()), SLOT(showContextHelp()));
|
|
|
|
connect(m_scene, SIGNAL(minimizeWindow()), SLOT(minimize()));
|
|
|
|
connect(m_scene, SIGNAL(menuClicked()), SLOT(menuClicked()));
|
|
|
|
connect(m_scene, SIGNAL(menuDblClicked()), SLOT(closeWindow()));
|
|
|
|
connect(m_scene, SIGNAL(toggleOnAllDesktops()), SLOT(toggleOnAllDesktops()));
|
|
|
|
connect(m_scene, SIGNAL(toggleShade()), SLOT(toggleShade()));
|
|
|
|
connect(m_scene, SIGNAL(toggleKeepAbove()), SLOT(toggleKeepAbove()));
|
|
|
|
connect(m_scene, SIGNAL(toggleKeepBelow()), SLOT(toggleKeepBelow()));
|
|
|
|
connect(m_scene, SIGNAL(titlePressed(Qt::MouseButton,Qt::MouseButtons)),
|
|
|
|
SLOT(titlePressed(Qt::MouseButton,Qt::MouseButtons)));
|
|
|
|
connect(m_scene, SIGNAL(titleReleased(Qt::MouseButton,Qt::MouseButtons)),
|
|
|
|
SLOT(titleReleased(Qt::MouseButton,Qt::MouseButtons)));
|
|
|
|
connect(m_scene, SIGNAL(titleDoubleClicked()), SLOT(titlebarDblClickOperation()));
|
|
|
|
connect(m_scene, SIGNAL(titleMouseMoved(Qt::MouseButton,Qt::MouseButtons)),
|
|
|
|
SLOT(titleMouseMoved(Qt::MouseButton,Qt::MouseButtons)));
|
|
|
|
connect(m_scene, SIGNAL(wheelEvent(int)), SLOT(titlebarMouseWheelOperation(int)));
|
2010-05-09 09:08:09 +00:00
|
|
|
connect(m_scene, SIGNAL(tabMouseButtonPress(QGraphicsSceneMouseEvent*,int)),
|
|
|
|
SLOT(tabMouseButtonPress(QGraphicsSceneMouseEvent*,int)));
|
|
|
|
connect(m_scene, SIGNAL(tabMouseButtonRelease(QGraphicsSceneMouseEvent*,int)),
|
|
|
|
SLOT(tabMouseButtonRelease(QGraphicsSceneMouseEvent*,int)));
|
2010-05-09 16:34:58 +00:00
|
|
|
connect(m_scene, SIGNAL(tabRemoved(int)), SLOT(tabRemoved(int)));
|
|
|
|
connect(m_scene, SIGNAL(tabMoved(int,int)), SLOT(tabMoved(int,int)));
|
|
|
|
connect(m_scene, SIGNAL(tabMovedToGroup(long int,int)), SLOT(tabMovedToGroup(long int,int)));
|
2010-04-12 19:28:58 +00:00
|
|
|
connect(this, SIGNAL(keepAboveChanged(bool)), SLOT(keepAboveChanged(bool)));
|
|
|
|
connect(this, SIGNAL(keepBelowChanged(bool)), SLOT(keepBelowChanged(bool)));
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-06-19 15:23:48 +00:00
|
|
|
AuroraeClient::~AuroraeClient()
|
|
|
|
{
|
|
|
|
m_view->setParent(NULL);
|
|
|
|
m_view->deleteLater();
|
|
|
|
m_scene->deleteLater();
|
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::init()
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
// HACK: we need to add the GraphicsView as a child widget to a normal widget
|
|
|
|
// the GraphicsView eats the mouse release event and by that kwin core starts to move
|
|
|
|
// the decoration each time the decoration is clicked
|
|
|
|
// therefore we use two widgets and inject an own mouse release event to the parent widget
|
|
|
|
// when the graphics view eats a mouse event
|
|
|
|
createMainWidget();
|
|
|
|
widget()->setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
widget()->setAttribute(Qt::WA_NoSystemBackground);
|
2010-05-09 09:08:09 +00:00
|
|
|
widget()->installEventFilter(this);
|
2010-04-12 19:28:58 +00:00
|
|
|
m_view = new QGraphicsView(m_scene, widget());
|
|
|
|
m_view->setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
m_view->setFrameShape(QFrame::NoFrame);
|
|
|
|
QPalette pal = m_view->palette();
|
|
|
|
pal.setColor(m_view->backgroundRole(), Qt::transparent);
|
|
|
|
m_view->setPalette(pal);
|
|
|
|
QPalette pal2 = widget()->palette();
|
|
|
|
pal2.setColor(widget()->backgroundRole(), Qt::transparent);
|
|
|
|
widget()->setPalette(pal2);
|
|
|
|
m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
// scene initialisation
|
|
|
|
m_scene->setActive(isActive(), false);
|
|
|
|
m_scene->setIcon(icon());
|
|
|
|
m_scene->setAllDesktops(isOnAllDesktops());
|
|
|
|
m_scene->setMaximizeMode(options()->moveResizeMaximizedWindows() ? MaximizeRestore : maximizeMode());
|
|
|
|
m_scene->setShade(isShade());
|
|
|
|
m_scene->setKeepAbove(keepAbove());
|
|
|
|
m_scene->setKeepBelow(keepBelow());
|
|
|
|
AuroraeFactory::instance()->theme()->setCompositingActive(compositingActive());
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::activeChange()
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
if (m_scene->isActive() != isActive()) {
|
|
|
|
m_scene->setActive(isActive());
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::captionChange()
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-05-09 09:08:09 +00:00
|
|
|
checkTabs(true);
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::iconChange()
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
m_scene->setIcon(icon());
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::desktopChange()
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
m_scene->setAllDesktops(isOnAllDesktops());
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::maximizeChange()
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
if (!options()->moveResizeMaximizedWindows()) {
|
|
|
|
m_scene->setMaximizeMode(maximizeMode());
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::resize(const QSize &s)
|
2010-01-29 12:37:42 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
m_scene->setSceneRect(QRectF(QPoint(0, 0), s));
|
|
|
|
m_scene->updateLayout();
|
|
|
|
m_view->resize(s);
|
|
|
|
widget()->resize(s);
|
|
|
|
updateWindowShape();
|
2010-01-29 12:37:42 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::shadeChange()
|
2010-01-29 12:37:42 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
m_scene->setShade(isShade());
|
2010-01-29 12:37:42 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::borders(int &left, int &right, int &top, int &bottom) const
|
2010-01-29 12:37:42 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
const bool maximized = maximizeMode() == MaximizeFull && !options()->moveResizeMaximizedWindows();
|
|
|
|
AuroraeFactory::instance()->theme()->borders(left, top, right, bottom, maximized);
|
2010-01-29 12:37:42 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::padding(int &left, int &right, int &top, int &bottom) const
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
AuroraeFactory::instance()->theme()->padding(left, top, right, bottom);
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
QSize AuroraeClient::minimumSize() const
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
return widget()->minimumSize();
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
KDecorationDefines::Position AuroraeClient::mousePosition(const QPoint &point) const
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
// based on the code from deKorator
|
|
|
|
int pos = PositionCenter;
|
|
|
|
if (isShade()) {
|
|
|
|
return Position(pos);
|
2009-10-31 17:06:31 +00:00
|
|
|
}
|
2009-06-19 09:18:07 +00:00
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
int borderLeft, borderTop, borderRight, borderBottom;
|
|
|
|
borders(borderLeft, borderRight, borderTop, borderBottom);
|
|
|
|
int paddingLeft, paddingTop, paddingRight, paddingBottom;
|
|
|
|
padding(paddingLeft, paddingRight, paddingTop, paddingBottom);
|
2010-04-27 17:50:13 +00:00
|
|
|
const bool maximized = maximizeMode() == MaximizeFull && !options()->moveResizeMaximizedWindows();
|
|
|
|
int titleEdgeLeft, titleEdgeRight, titleEdgeTop, titleEdgeBottom;
|
|
|
|
AuroraeFactory::instance()->theme()->titleEdges(titleEdgeLeft, titleEdgeTop, titleEdgeRight, titleEdgeBottom, maximized);
|
|
|
|
switch (AuroraeFactory::instance()->theme()->decorationPosition()) {
|
|
|
|
case DecorationTop:
|
|
|
|
borderTop = titleEdgeTop;
|
|
|
|
break;
|
|
|
|
case DecorationLeft:
|
|
|
|
borderLeft = titleEdgeLeft;
|
|
|
|
break;
|
|
|
|
case DecorationRight:
|
|
|
|
borderRight = titleEdgeRight;
|
|
|
|
break;
|
|
|
|
case DecorationBottom:
|
|
|
|
borderBottom = titleEdgeBottom;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break; // nothing
|
|
|
|
}
|
2010-04-24 07:45:42 +00:00
|
|
|
if (point.x() >= (m_view->width() - borderRight - paddingRight)) {
|
2010-04-12 19:28:58 +00:00
|
|
|
pos |= PositionRight;
|
|
|
|
} else if (point.x() <= borderLeft + paddingLeft) {
|
|
|
|
pos |= PositionLeft;
|
|
|
|
}
|
2009-06-19 09:18:07 +00:00
|
|
|
|
2010-04-24 07:45:42 +00:00
|
|
|
if (point.y() >= m_view->height() - borderBottom - paddingBottom) {
|
2010-04-12 19:28:58 +00:00
|
|
|
pos |= PositionBottom;
|
2010-04-27 17:50:13 +00:00
|
|
|
} else if (point.y() <= borderTop + paddingTop ) {
|
2010-04-12 19:28:58 +00:00
|
|
|
pos |= PositionTop;
|
|
|
|
}
|
2009-06-19 09:18:07 +00:00
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
return Position(pos);
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::reset(long unsigned int changed)
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
if (changed & SettingCompositing) {
|
|
|
|
updateWindowShape();
|
|
|
|
AuroraeFactory::instance()->theme()->setCompositingActive(compositingActive());
|
|
|
|
}
|
|
|
|
if (changed & SettingButtons) {
|
|
|
|
m_scene->setButtons(options()->customButtonPositions() ? options()->titleButtonsLeft() : AuroraeFactory::instance()->theme()->defaultButtonsLeft(),
|
|
|
|
options()->customButtonPositions() ? options()->titleButtonsRight() : AuroraeFactory::instance()->theme()->defaultButtonsRight());
|
|
|
|
}
|
|
|
|
KDecoration::reset(changed);
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::menuClicked()
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
showWindowMenu(QCursor::pos());
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::toggleShade()
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
setShade(!isShade());
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::keepAboveChanged(bool above)
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
if (above && m_scene->isKeepBelow()) {
|
|
|
|
m_scene->setKeepBelow(false);
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
2010-04-12 19:28:58 +00:00
|
|
|
m_scene->setKeepAbove(above);
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::keepBelowChanged(bool below)
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
if (below && m_scene->isKeepAbove()) {
|
|
|
|
m_scene->setKeepAbove(false);
|
2009-11-01 12:12:30 +00:00
|
|
|
}
|
2010-04-12 19:28:58 +00:00
|
|
|
m_scene->setKeepBelow(below);
|
2009-11-01 12:12:30 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::toggleKeepAbove()
|
2009-11-01 12:12:30 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
setKeepAbove(!keepAbove());
|
2009-11-01 12:12:30 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::toggleKeepBelow()
|
2009-11-01 12:12:30 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
setKeepBelow(!keepBelow());
|
2009-06-19 09:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AuroraeClient::updateWindowShape()
|
|
|
|
{
|
|
|
|
bool maximized = maximizeMode()==KDecorationDefines::MaximizeFull && !options()->moveResizeMaximizedWindows();
|
|
|
|
int w=widget()->width();
|
|
|
|
int h=widget()->height();
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
if (maximized || compositingActive()) {
|
2009-06-19 09:18:07 +00:00
|
|
|
QRegion mask(0,0,w,h);
|
|
|
|
setMask(mask);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
int pl, pt, pr, pb;
|
|
|
|
padding(pl, pr, pt, pb);
|
|
|
|
Plasma::FrameSvg *deco = AuroraeFactory::instance()->theme()->decoration();
|
2009-06-19 09:18:07 +00:00
|
|
|
if (!deco->hasElementPrefix("decoration-opaque")) {
|
|
|
|
// opaque element is missing: set generic mask
|
2010-04-12 19:28:58 +00:00
|
|
|
w = w - pl - pr;
|
|
|
|
h = h - pt - pb;
|
|
|
|
QRegion mask(pl, pt, w, h);
|
2009-06-19 09:18:07 +00:00
|
|
|
setMask(mask);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
deco->setElementPrefix("decoration-opaque");
|
2010-04-12 19:28:58 +00:00
|
|
|
deco->resizeFrame(QSize(w-pl-pr, h-pt-pb));
|
|
|
|
QRegion mask = deco->mask().translated(pl, pt);
|
2009-06-19 09:18:07 +00:00
|
|
|
setMask(mask);
|
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::titlePressed(Qt::MouseButton button, Qt::MouseButtons buttons)
|
2010-01-29 12:37:42 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonPress, widget()->mapFromGlobal(QCursor::pos()),
|
|
|
|
QCursor::pos(), button, buttons, Qt::NoModifier);
|
|
|
|
processMousePressEvent(event);
|
|
|
|
delete event;
|
|
|
|
event = 0;
|
2010-01-29 12:37:42 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::titleReleased(Qt::MouseButton button, Qt::MouseButtons buttons)
|
2010-01-29 12:37:42 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonRelease, widget()->mapFromGlobal(QCursor::pos()),
|
|
|
|
QCursor::pos(), button, buttons, Qt::NoModifier);
|
|
|
|
QApplication::sendEvent(widget(), event);
|
|
|
|
delete event;
|
|
|
|
event = 0;
|
2010-01-29 12:37:42 +00:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
void AuroraeClient::titleMouseMoved(Qt::MouseButton button, Qt::MouseButtons buttons)
|
2010-01-29 12:37:42 +00:00
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
QMouseEvent *event = new QMouseEvent(QEvent::MouseMove, widget()->mapFromGlobal(QCursor::pos()),
|
|
|
|
QCursor::pos(), button, buttons, Qt::NoModifier);
|
|
|
|
QApplication::sendEvent(widget(), event);
|
|
|
|
delete event;
|
|
|
|
event = 0;
|
2010-01-29 12:37:42 +00:00
|
|
|
}
|
|
|
|
|
2010-05-09 09:08:09 +00:00
|
|
|
void AuroraeClient::checkTabs(bool force)
|
|
|
|
{
|
|
|
|
if (m_scene->tabCount() == 1 && clientGroupItems().count() == 1 && !force) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (m_scene->tabCount() < clientGroupItems().count()) {
|
|
|
|
m_scene->addTab(QString());
|
|
|
|
}
|
|
|
|
while (m_scene->tabCount() > clientGroupItems().count()) {
|
|
|
|
m_scene->removeLastTab();
|
|
|
|
}
|
2010-10-21 18:19:01 +00:00
|
|
|
QList<AuroraeTabData> data;
|
2010-05-09 09:08:09 +00:00
|
|
|
foreach (const ClientGroupItem &item, clientGroupItems()) {
|
2010-10-21 18:19:01 +00:00
|
|
|
data << AuroraeTabData(item.title(), item.icon());
|
2010-05-09 09:08:09 +00:00
|
|
|
}
|
2010-10-21 18:19:01 +00:00
|
|
|
m_scene->setAllTabData(data);
|
2010-05-09 09:08:09 +00:00
|
|
|
m_scene->setFocusedTab(visibleClientGroupItem());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AuroraeClient::eventFilter(QObject *o, QEvent *e)
|
|
|
|
{
|
|
|
|
if (o != widget()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (e->type() == QEvent::Paint) {
|
|
|
|
checkTabs();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AuroraeClient::tabMouseButtonPress(QGraphicsSceneMouseEvent *e, int index)
|
|
|
|
{
|
|
|
|
if (buttonToWindowOperation(e->buttons()) == OperationsOp) {
|
|
|
|
displayClientMenu(index, e->screenPos());
|
|
|
|
return;
|
2010-05-09 16:34:58 +00:00
|
|
|
} else if (buttonToWindowOperation(e->buttons()) == ClientGroupDragOp) {
|
|
|
|
m_scene->setUniqueTabDragId(index, itemId(index));
|
2010-05-09 09:08:09 +00:00
|
|
|
}
|
|
|
|
titlePressed(e->button(), e->buttons());
|
|
|
|
m_clickInProgress = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AuroraeClient::tabMouseButtonRelease(QGraphicsSceneMouseEvent *e, int index)
|
|
|
|
{
|
|
|
|
if (m_clickInProgress) {
|
|
|
|
setVisibleClientGroupItem(index);
|
|
|
|
}
|
|
|
|
titleReleased(e->button(), e->buttons());
|
|
|
|
m_clickInProgress = false;
|
|
|
|
}
|
|
|
|
|
2010-05-09 16:34:58 +00:00
|
|
|
void AuroraeClient::tabRemoved(int index)
|
|
|
|
{
|
|
|
|
removeFromClientGroup(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AuroraeClient::tabMoved(int index, int before)
|
|
|
|
{
|
|
|
|
moveItemInClientGroup(index, before);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AuroraeClient::tabMovedToGroup(long int uid, int before)
|
|
|
|
{
|
|
|
|
moveItemToClientGroup(uid, before);
|
|
|
|
}
|
|
|
|
|
2009-06-19 09:18:07 +00:00
|
|
|
} // namespace Aurorae
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
KDE_EXPORT KDecorationFactory *create_factory() {
|
|
|
|
return Aurorae::AuroraeFactory::instance();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#include "aurorae.moc"
|