2007-04-29 17:35:43 +00:00
|
|
|
/*****************************************************************
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
copy of this software and associated documentation files (the "Software"),
|
|
|
|
to deal in the Software without restriction, including without limitation
|
|
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
DEALINGS IN THE SOFTWARE.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include "kdecoration.h"
|
2008-05-30 17:47:24 +00:00
|
|
|
#include "kdecoration_p.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <QApplication>
|
2012-11-23 11:44:53 +00:00
|
|
|
#include <QMenu>
|
2013-10-08 06:33:23 +00:00
|
|
|
#include <QWindow>
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KConfigGroup>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <fixx11h.h>
|
|
|
|
|
|
|
|
#include "kdecorationfactory.h"
|
2008-01-26 19:00:14 +00:00
|
|
|
#include "kdecorationbridge.h"
|
2007-11-29 14:11:02 +00:00
|
|
|
|
2012-11-09 12:44:50 +00:00
|
|
|
|
2007-11-29 14:11:02 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
Extending KDecoration:
|
|
|
|
======================
|
|
|
|
|
|
|
|
If KDecoration will ever need to be extended in a way that'd break binary compatibility
|
|
|
|
(i.e. adding new virtual methods most probably), new class KDecoration2 should be
|
|
|
|
inherited from KDecoration and those methods added there. Code that would depend
|
|
|
|
on the new functionality could then dynamic_cast<> to KDecoration2 to check whether
|
|
|
|
it is available and use it.
|
|
|
|
|
|
|
|
KCommonDecoration would have to be extended the same way, adding KCommonDecoration2
|
|
|
|
inheriting KCommonDecoration and adding the new API matching KDecoration2.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2012-10-12 09:34:05 +00:00
|
|
|
class KDecorationPrivate
|
|
|
|
{
|
|
|
|
public:
|
2013-08-24 08:48:43 +00:00
|
|
|
KDecorationPrivate(KDecorationBridge *b, KDecorationFactory *f)
|
2013-08-24 08:26:31 +00:00
|
|
|
: bridge(b)
|
2013-08-24 08:48:43 +00:00
|
|
|
, factory(f)
|
2013-08-24 08:26:31 +00:00
|
|
|
, alphaEnabled(false)
|
2013-08-24 08:41:29 +00:00
|
|
|
, w()
|
2013-10-08 06:33:23 +00:00
|
|
|
, window()
|
2012-10-12 09:34:05 +00:00
|
|
|
{
|
|
|
|
}
|
2013-08-24 08:26:31 +00:00
|
|
|
KDecorationBridge *bridge;
|
2013-08-24 08:48:43 +00:00
|
|
|
KDecorationFactory *factory;
|
2012-10-12 09:34:05 +00:00
|
|
|
bool alphaEnabled;
|
2013-08-24 08:41:29 +00:00
|
|
|
QScopedPointer<QWidget> w;
|
2013-10-08 06:33:23 +00:00
|
|
|
QScopedPointer<QWindow> window;
|
2012-10-12 09:34:05 +00:00
|
|
|
};
|
2007-11-29 14:11:02 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KDecoration::KDecoration(KDecorationBridge* bridge, KDecorationFactory* factory)
|
2013-08-24 08:48:43 +00:00
|
|
|
: d(new KDecorationPrivate(bridge, factory))
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
factory->addDecoration(this);
|
2013-08-23 17:18:25 +00:00
|
|
|
connect(this, static_cast<void (KDecoration::*)(bool)>(&KDecoration::keepAboveChanged),
|
|
|
|
this, static_cast<void (KDecoration::*)()>(&KDecoration::keepAboveChanged));
|
|
|
|
connect(this, static_cast<void (KDecoration::*)(bool)>(&KDecoration::keepBelowChanged),
|
|
|
|
this, static_cast<void (KDecoration::*)()>(&KDecoration::keepBelowChanged));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
KDecoration::~KDecoration()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
factory()->removeDecoration(this);
|
2012-10-12 09:34:05 +00:00
|
|
|
delete d;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
const KDecorationOptions* KDecoration::options()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:59:52 +00:00
|
|
|
return KDecorationOptions::self();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-08-07 11:53:11 +00:00
|
|
|
void KDecoration::createMainWidget(Qt::WindowFlags flags)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// FRAME check flags?
|
2013-10-08 05:22:19 +00:00
|
|
|
QWidget *w = new QWidget(nullptr, initialWFlags() | flags);
|
2011-01-30 14:34:42 +00:00
|
|
|
w->setObjectName(QLatin1String("decoration widget"));
|
|
|
|
if (options()->showTooltips())
|
|
|
|
w->setAttribute(Qt::WA_AlwaysShowToolTips);
|
2007-04-29 17:35:43 +00:00
|
|
|
setMainWidget(w);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecoration::setMainWidget(QWidget* w)
|
|
|
|
{
|
2013-08-24 08:41:29 +00:00
|
|
|
assert(d->w.isNull());
|
|
|
|
d->w.reset(w);
|
2011-01-30 14:34:42 +00:00
|
|
|
w->setMouseTracking(true);
|
|
|
|
widget()->resize(geometry().size());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-10-08 07:57:53 +00:00
|
|
|
void KDecoration::setMainWindow(QWindow *window)
|
|
|
|
{
|
|
|
|
assert(d->window.isNull());
|
|
|
|
d->window.reset(window);
|
|
|
|
d->window->resize(geometry().size());
|
|
|
|
}
|
|
|
|
|
2013-08-07 11:53:11 +00:00
|
|
|
Qt::WindowFlags KDecoration::initialWFlags() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->initialWFlags();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-10-08 07:57:53 +00:00
|
|
|
void KDecoration::show()
|
|
|
|
{
|
|
|
|
if (!d->w.isNull()) {
|
|
|
|
d->w->show();
|
|
|
|
} else if (!d->window.isNull()) {
|
|
|
|
d->window->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KDecoration::hide()
|
|
|
|
{
|
|
|
|
if (!d->w.isNull()) {
|
|
|
|
d->w->hide();
|
|
|
|
} else if (!d->window.isNull()) {
|
|
|
|
d->window->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect KDecoration::rect() const
|
|
|
|
{
|
|
|
|
if (!d->w.isNull()) {
|
|
|
|
return d->w->rect();
|
|
|
|
} else if (!d->window.isNull()) {
|
|
|
|
return QRect(QPoint(0, 0), d->window->size());
|
|
|
|
}
|
|
|
|
return QRect();
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecoration::isActive() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isActive();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecoration::isCloseable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isCloseable();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecoration::isMaximizable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isMaximizable();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
KDecoration::MaximizeMode KDecoration::maximizeMode() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->maximizeMode();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2013-08-23 16:42:37 +00:00
|
|
|
bool KDecoration::isMaximized() const
|
|
|
|
{
|
|
|
|
return maximizeMode() == MaximizeFull;
|
|
|
|
}
|
|
|
|
|
2013-02-17 00:56:01 +00:00
|
|
|
KDecoration::QuickTileMode KDecoration::quickTileMode() const
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->quickTileMode();
|
2013-02-17 00:56:01 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecoration::isMinimizable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isMinimizable();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecoration::providesContextHelp() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->providesContextHelp();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
int KDecoration::desktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->desktop();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecoration::isModal() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isModal();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecoration::isShadeable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isShadeable();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecoration::isShade() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isShade();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecoration::isSetShade() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isSetShade();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecoration::keepAbove() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->keepAbove();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecoration::keepBelow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->keepBelow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecoration::isMovable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isMovable();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecoration::isResizable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isResizable();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
NET::WindowType KDecoration::windowType(unsigned long supported_types) const
|
|
|
|
{
|
|
|
|
// this one is also duplicated in KDecorationFactory
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->windowType(supported_types);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QIcon KDecoration::icon() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->icon();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
QString KDecoration::caption() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->caption();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecoration::processMousePressEvent(QMouseEvent* e)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->processMousePressEvent(e);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecoration::showWindowMenu(const QRect &pos)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->showWindowMenu(pos);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecoration::showWindowMenu(QPoint pos)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->showWindowMenu(pos);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-11-09 12:44:50 +00:00
|
|
|
void KDecoration::showApplicationMenu(const QPoint &p)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->showApplicationMenu(p);
|
2012-11-09 12:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KDecoration::menuAvailable() const
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->menuAvailable();
|
2012-11-09 12:44:50 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecoration::performWindowOperation(WindowOperation op)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->performWindowOperation(op);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecoration::setMask(const QRegion& reg, int mode)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->setMask(reg, mode);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void KDecoration::clearMask()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->setMask(QRegion(), 0);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecoration::isPreview() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->isPreview();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
QRect KDecoration::geometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
QRect KDecoration::iconGeometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->iconGeometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRegion KDecoration::unobscuredRegion(const QRegion& r) const
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->unobscuredRegion(r);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
WId KDecoration::windowId() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->windowId();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void KDecoration::closeWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->closeWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecoration::maximize(Qt::MouseButtons button)
|
|
|
|
{
|
|
|
|
performWindowOperation(options()->operationMaxButtonClick(button));
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecoration::maximize(MaximizeMode mode)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->maximize(mode);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void KDecoration::minimize()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->minimize();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecoration::showContextHelp()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->showContextHelp();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecoration::setDesktop(int desktop)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->setDesktop(desktop);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecoration::toggleOnAllDesktops()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (isOnAllDesktops())
|
2013-08-24 08:26:31 +00:00
|
|
|
setDesktop(d->bridge->currentDesktop());
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
setDesktop(NET::OnAllDesktops);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecoration::titlebarDblClickOperation()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->titlebarDblClickOperation();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KDecoration::titlebarMouseWheelOperation(int delta)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->titlebarMouseWheelOperation(delta);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KDecoration::setShade(bool set)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->setShade(set);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KDecoration::setKeepAbove(bool set)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->setKeepAbove(set);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KDecoration::setKeepBelow(bool set)
|
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->setKeepBelow(set);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KDecoration::windowDocked(Position)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecoration::grabXServer()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->grabXServer(true);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void KDecoration::ungrabXServer()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->grabXServer(false);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-20 16:00:58 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KDecoration::Position KDecoration::mousePosition(const QPoint& p) const
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
const int range = 16;
|
|
|
|
int bleft, bright, btop, bbottom;
|
2011-01-30 14:34:42 +00:00
|
|
|
borders(bleft, bright, btop, bbottom);
|
|
|
|
btop = qMin(btop, 4); // otherwise whole titlebar would have resize cursor
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Position m = PositionCenter;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if ((p.x() > bleft && p.x() < widget()->width() - bright)
|
|
|
|
&& (p.y() > btop && p.y() < widget()->height() - bbottom))
|
2007-04-29 17:35:43 +00:00
|
|
|
return PositionCenter;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (p.y() <= qMax(range, btop) && p.x() <= qMax(range, bleft))
|
2007-04-29 17:35:43 +00:00
|
|
|
m = PositionTopLeft;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p.y() >= widget()->height() - qMax(range, bbottom)
|
|
|
|
&& p.x() >= widget()->width() - qMax(range, bright))
|
2007-04-29 17:35:43 +00:00
|
|
|
m = PositionBottomRight;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p.y() >= widget()->height() - qMax(range, bbottom) && p.x() <= qMax(range, bleft))
|
2007-04-29 17:35:43 +00:00
|
|
|
m = PositionBottomLeft;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p.y() <= qMax(range, btop) && p.x() >= widget()->width() - qMax(range, bright))
|
2007-04-29 17:35:43 +00:00
|
|
|
m = PositionTopRight;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p.y() <= btop)
|
2007-04-29 17:35:43 +00:00
|
|
|
m = PositionTop;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p.y() >= widget()->height() - bbottom)
|
2007-04-29 17:35:43 +00:00
|
|
|
m = PositionBottom;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p.x() <= bleft)
|
2007-04-29 17:35:43 +00:00
|
|
|
m = PositionLeft;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (p.x() >= widget()->width() - bright)
|
2007-04-29 17:35:43 +00:00
|
|
|
m = PositionRight;
|
|
|
|
else
|
|
|
|
m = PositionCenter;
|
|
|
|
return m;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-11-25 23:32:35 +00:00
|
|
|
QRect KDecoration::transparentRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->transparentRect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-25 23:32:35 +00:00
|
|
|
|
2012-10-12 09:34:05 +00:00
|
|
|
void KDecoration::setAlphaEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
if (d->alphaEnabled == enabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
d->alphaEnabled = enabled;
|
|
|
|
emit alphaEnabledChanged(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KDecoration::isAlphaEnabled() const
|
|
|
|
{
|
|
|
|
return d->alphaEnabled;
|
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
bool KDecoration::compositingActive() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->compositingActive();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2013-10-14 05:21:44 +00:00
|
|
|
QPalette KDecoration::palette() const
|
|
|
|
{
|
|
|
|
return d->bridge->palette();
|
|
|
|
}
|
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
void KDecoration::padding(int &left, int &right, int &top, int &bottom) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-05-04 22:35:33 +00:00
|
|
|
left = right = top = bottom = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
//BEGIN Window tabbing
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
int KDecoration::tabCount() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->tabCount();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
long KDecoration::tabId(int idx) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->tabId(idx);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
QString KDecoration::caption(int idx) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->caption(idx);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
QIcon KDecoration::icon(int idx) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->icon(idx);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
long KDecoration::currentTabId() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->currentTabId();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
void KDecoration::setCurrentTab(long id)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->setCurrentTab(id);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
void KDecoration::tab_A_before_B(long A, long B)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->tab_A_before_B(A, B);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
void KDecoration::tab_A_behind_B(long A, long B)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->tab_A_behind_B(A, B);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
void KDecoration::untab(long id, const QRect& newGeom)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->untab(id, newGeom);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
void KDecoration::closeTab(long id)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->closeTab(id);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
void KDecoration::closeTabGroup()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->closeTabGroup();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
void KDecoration::showWindowMenu(const QPoint &pos, long id)
|
2012-01-12 06:42:55 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
d->bridge->showWindowMenu(pos, id);
|
2012-01-12 06:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//END tabbing
|
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
KDecoration::WindowOperation KDecoration::buttonToWindowOperation(Qt::MouseButtons button)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:26:31 +00:00
|
|
|
return d->bridge->buttonToWindowOperation(button);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-10-03 17:00:56 +00:00
|
|
|
QRegion KDecoration::region(KDecorationDefines::Region)
|
2011-11-09 18:51:23 +00:00
|
|
|
{
|
|
|
|
return QRegion();
|
|
|
|
}
|
|
|
|
|
2013-02-17 00:56:01 +00:00
|
|
|
KDecorationDefines::Position KDecoration::titlebarPosition()
|
|
|
|
{
|
|
|
|
return PositionTop;
|
|
|
|
}
|
|
|
|
|
2013-08-24 08:16:11 +00:00
|
|
|
QWidget* KDecoration::widget()
|
|
|
|
{
|
2013-08-24 08:41:29 +00:00
|
|
|
return d->w.data();
|
2013-08-24 08:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const QWidget* KDecoration::widget() const
|
|
|
|
{
|
2013-08-24 08:41:29 +00:00
|
|
|
return d->w.data();
|
2013-08-24 08:16:11 +00:00
|
|
|
}
|
|
|
|
|
2013-10-08 06:33:23 +00:00
|
|
|
QWindow *KDecoration::window()
|
|
|
|
{
|
|
|
|
if (!d->window.isNull()) {
|
|
|
|
return d->window.data();
|
|
|
|
}
|
|
|
|
if (!d->w.isNull()) {
|
|
|
|
// we have a widget
|
|
|
|
if (d->w->windowHandle()) {
|
|
|
|
// the window exists, so return it
|
|
|
|
return d->w->windowHandle();
|
|
|
|
} else {
|
|
|
|
// access window Id to generate the handle
|
|
|
|
WId tempId = d->w->winId();
|
|
|
|
Q_UNUSED(tempId)
|
|
|
|
return d->w->windowHandle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// neither window, nor widget are set
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-08-24 08:16:11 +00:00
|
|
|
KDecorationFactory* KDecoration::factory() const
|
|
|
|
{
|
2013-08-24 08:48:43 +00:00
|
|
|
return d->factory;
|
2013-08-24 08:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool KDecoration::isOnAllDesktops() const
|
|
|
|
{
|
|
|
|
return desktop() == NET::OnAllDesktops;
|
|
|
|
}
|
|
|
|
|
2014-02-26 10:26:00 +00:00
|
|
|
bool KDecoration::isOnAllDesktopsAvailable() const
|
|
|
|
{
|
|
|
|
return d->bridge->isOnAllDesktopsAvailable();
|
|
|
|
}
|
|
|
|
|
2013-08-24 08:16:11 +00:00
|
|
|
int KDecoration::width() const
|
|
|
|
{
|
|
|
|
return geometry().width();
|
|
|
|
}
|
|
|
|
|
|
|
|
int KDecoration::height() const
|
|
|
|
{
|
|
|
|
return geometry().height();
|
|
|
|
}
|
|
|
|
|
2013-10-07 12:26:03 +00:00
|
|
|
void KDecoration::render(QPaintDevice* device, const QRegion& sourceRegion)
|
|
|
|
{
|
|
|
|
if (!widget()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// do not use DrawWindowBackground, it's ok to be transparent
|
|
|
|
widget()->render(device, QPoint(), sourceRegion, QWidget::DrawChildren);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KDecoration::update()
|
|
|
|
{
|
|
|
|
int left, right, top, bottom;
|
|
|
|
left = right = top = bottom = 0;
|
|
|
|
padding(left, right, top, bottom);
|
|
|
|
update(QRegion(0, 0, width() + left + right, height() + top + bottom));
|
|
|
|
}
|
|
|
|
|
|
|
|
void KDecoration::update(const QRect &rect)
|
|
|
|
{
|
|
|
|
update(QRegion(rect));
|
|
|
|
}
|
|
|
|
|
|
|
|
void KDecoration::update(const QRegion ®ion)
|
|
|
|
{
|
|
|
|
d->bridge->update(region);
|
|
|
|
}
|
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
QString KDecorationDefines::tabDragMimeType()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-23 05:02:52 +00:00
|
|
|
return QStringLiteral("text/ClientGroupItem");
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2013-08-24 08:59:52 +00:00
|
|
|
KDecorationOptions* KDecorationOptions::s_self = nullptr;
|
|
|
|
|
2013-08-23 11:18:04 +00:00
|
|
|
KDecorationOptions::KDecorationOptions(QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, d(new KDecorationOptionsPrivate(this))
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:59:52 +00:00
|
|
|
assert(s_self == nullptr);
|
|
|
|
s_self = this;
|
2013-08-23 11:18:04 +00:00
|
|
|
connect(this, &KDecorationOptions::activeFontChanged, this, &KDecorationOptions::fontsChanged);
|
|
|
|
connect(this, &KDecorationOptions::inactiveFontChanged, this, &KDecorationOptions::fontsChanged);
|
|
|
|
connect(this, &KDecorationOptions::smallActiveFontChanged, this, &KDecorationOptions::fontsChanged);
|
|
|
|
connect(this, &KDecorationOptions::smallInactiveFontChanged, this, &KDecorationOptions::fontsChanged);
|
|
|
|
connect(this, &KDecorationOptions::leftButtonsChanged, this, &KDecorationOptions::buttonsChanged);
|
|
|
|
connect(this, &KDecorationOptions::rightButtonsChanged, this, &KDecorationOptions::buttonsChanged);
|
|
|
|
connect(this, &KDecorationOptions::customButtonPositionsChanged, this, &KDecorationOptions::buttonsChanged);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
KDecorationOptions::~KDecorationOptions()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-24 08:59:52 +00:00
|
|
|
assert(s_self == this);
|
|
|
|
s_self = nullptr;
|
2008-01-29 16:44:41 +00:00
|
|
|
delete d;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-08-24 08:59:52 +00:00
|
|
|
KDecorationOptions* KDecorationOptions::self()
|
|
|
|
{
|
|
|
|
return s_self;
|
|
|
|
}
|
|
|
|
|
2007-07-25 10:28:57 +00:00
|
|
|
QColor KDecorationOptions::color(ColorType type, bool active) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return(d->colors[type + (active ? 0 : NUM_COLORS)]);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-07-25 10:28:57 +00:00
|
|
|
QFont KDecorationOptions::font(bool active, bool small) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (small)
|
2007-04-29 17:35:43 +00:00
|
|
|
return(active ? d->activeFontSmall : d->inactiveFontSmall);
|
|
|
|
else
|
|
|
|
return(active ? d->activeFont : d->inactiveFont);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-07-25 10:28:57 +00:00
|
|
|
QPalette KDecorationOptions::palette(ColorType type, bool active) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
int idx = type + (active ? 0 : NUM_COLORS);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (d->pal[idx])
|
2007-04-29 17:35:43 +00:00
|
|
|
return(*d->pal[idx]);
|
2009-10-05 06:59:10 +00:00
|
|
|
// TODO: Why construct the palette this way? Is it worth porting to Qt4?
|
|
|
|
//d->pal[idx] = new QPalette(Qt::black, d->colors[idx], d->colors[idx].light(150),
|
|
|
|
// d->colors[idx].dark(), d->colors[idx].dark(120),
|
|
|
|
// Qt::black, QApplication::palette().active().
|
|
|
|
// base());
|
2007-04-29 17:35:43 +00:00
|
|
|
d->pal[idx] = new QPalette(d->colors[idx]);
|
|
|
|
return(*d->pal[idx]);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-29 16:44:41 +00:00
|
|
|
|
2013-08-23 11:18:04 +00:00
|
|
|
void KDecorationOptions::updateSettings(KConfig* config)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-23 11:18:04 +00:00
|
|
|
d->updateSettings(config);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationOptions::customButtonPositions() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return d->custom_button_positions;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-10-10 08:03:51 +00:00
|
|
|
QList<KDecorationDefines::DecorationButton> KDecorationOptions::titleButtonsLeft() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return d->title_buttons_left;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-10-10 08:03:51 +00:00
|
|
|
QList<KDecorationDefines::DecorationButton> KDecorationOptions::defaultTitleButtonsLeft()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-10-10 08:03:51 +00:00
|
|
|
return QList<DecorationButton>() << DecorationButtonMenu
|
|
|
|
<< DecorationButtonOnAllDesktops;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-15 20:08:57 +00:00
|
|
|
|
2013-10-10 08:03:51 +00:00
|
|
|
QList<KDecorationDefines::DecorationButton> KDecorationOptions::titleButtonsRight() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return d->title_buttons_right;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-10-10 08:03:51 +00:00
|
|
|
QList<KDecorationDefines::DecorationButton> KDecorationOptions::defaultTitleButtonsRight()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-10-10 08:03:51 +00:00
|
|
|
return QList<DecorationButton>() << DecorationButtonQuickHelp
|
|
|
|
<< DecorationButtonMinimize
|
|
|
|
<< DecorationButtonMaximizeRestore
|
|
|
|
<< DecorationButtonClose;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-15 20:08:57 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool KDecorationOptions::showTooltips() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return d->show_tooltips;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KDecorationOptions::BorderSize KDecorationOptions::preferredBorderSize(KDecorationFactory* factory) const
|
|
|
|
{
|
2014-02-24 15:47:48 +00:00
|
|
|
assert(factory != nullptr);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (d->cached_border_size == BordersCount) // invalid
|
|
|
|
d->cached_border_size = d->findPreferredBorderSize(d->border_size,
|
|
|
|
factory->borderSizes());
|
2007-04-29 17:35:43 +00:00
|
|
|
return d->cached_border_size;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KDecorationDefines::WindowOperation KDecorationOptions::operationMaxButtonClick(Qt::MouseButtons button) const
|
|
|
|
{
|
|
|
|
return button == Qt::RightButton ? d->opMaxButtonRightClick :
|
|
|
|
button == Qt::MidButton ? d->opMaxButtonMiddleClick :
|
|
|
|
d->opMaxButtonLeftClick;
|
|
|
|
}
|
2008-01-29 16:44:41 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationOptions::setOpMaxButtonLeftClick(WindowOperation op)
|
|
|
|
{
|
2008-01-29 16:44:41 +00:00
|
|
|
d->opMaxButtonLeftClick = op;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-29 16:44:41 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationOptions::setOpMaxButtonRightClick(WindowOperation op)
|
|
|
|
{
|
2008-01-29 16:44:41 +00:00
|
|
|
d->opMaxButtonRightClick = op;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-29 16:44:41 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationOptions::setOpMaxButtonMiddleClick(WindowOperation op)
|
|
|
|
{
|
2008-01-29 16:44:41 +00:00
|
|
|
d->opMaxButtonMiddleClick = op;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-29 16:44:41 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationOptions::setBorderSize(BorderSize bs)
|
|
|
|
{
|
2008-01-29 16:44:41 +00:00
|
|
|
d->border_size = bs;
|
|
|
|
d->cached_border_size = BordersCount; // invalid
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-29 16:44:41 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationOptions::setCustomButtonPositions(bool b)
|
|
|
|
{
|
2008-01-29 16:44:41 +00:00
|
|
|
d->custom_button_positions = b;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-29 16:44:41 +00:00
|
|
|
|
2013-10-10 08:03:51 +00:00
|
|
|
void KDecorationOptions::setTitleButtonsLeft(const QList<DecorationButton>& b)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-01-29 16:44:41 +00:00
|
|
|
d->title_buttons_left = b;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-29 16:44:41 +00:00
|
|
|
|
2013-10-10 08:03:51 +00:00
|
|
|
void KDecorationOptions::setTitleButtonsRight(const QList<DecorationButton>& b)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-01-29 16:44:41 +00:00
|
|
|
d->title_buttons_right = b;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-29 16:44:41 +00:00
|
|
|
|
2013-10-10 08:03:51 +00:00
|
|
|
|
|
|
|
static QHash<KDecorationDefines::DecorationButton, QByteArray> s_buttonNames;
|
|
|
|
static void initButtons()
|
|
|
|
{
|
|
|
|
if (!s_buttonNames.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonMenu] = QByteArrayLiteral("M");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonApplicationMenu] = QByteArrayLiteral("N");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonOnAllDesktops] = QByteArrayLiteral("S");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonQuickHelp] = QByteArrayLiteral("H");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonMinimize] = QByteArrayLiteral("I");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonMaximizeRestore] = QByteArrayLiteral("A");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonClose] = QByteArrayLiteral("X");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonKeepAbove] = QByteArrayLiteral("F");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonKeepBelow] = QByteArrayLiteral("B");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonShade] = QByteArrayLiteral("L");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonResize] = QByteArrayLiteral("R");
|
|
|
|
s_buttonNames[KDecorationDefines::DecorationButtonExplicitSpacer] = QByteArrayLiteral("_");
|
|
|
|
}
|
|
|
|
|
|
|
|
static QString buttonsToString(const QList<KDecorationDefines::DecorationButton> &buttons)
|
|
|
|
{
|
|
|
|
auto buttonToString = [](KDecorationDefines::DecorationButton button) -> QByteArray {
|
|
|
|
const auto it = s_buttonNames.constFind(button);
|
|
|
|
if (it != s_buttonNames.constEnd()) {
|
|
|
|
return it.value();
|
|
|
|
}
|
|
|
|
return QByteArray();
|
|
|
|
};
|
|
|
|
QByteArray ret;
|
|
|
|
for (auto button : buttons) {
|
|
|
|
ret.append(buttonToString(button));
|
|
|
|
}
|
|
|
|
return QString::fromUtf8(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
QList< KDecorationDefines::DecorationButton > KDecorationOptions::readDecorationButtons(const KConfigGroup &config,
|
|
|
|
const char *key,
|
|
|
|
const QList< DecorationButton > &defaultValue)
|
|
|
|
{
|
|
|
|
initButtons();
|
|
|
|
auto buttonFromString = [](const QByteArray &button) -> DecorationButton {
|
|
|
|
return s_buttonNames.key(button, DecorationButtonNone);
|
|
|
|
};
|
|
|
|
auto buttonsFromString = [buttonFromString](const QString &buttons) -> QList<DecorationButton> {
|
|
|
|
QList<DecorationButton> ret;
|
|
|
|
for (auto it = buttons.constBegin(); it != buttons.constEnd(); ++it) {
|
|
|
|
char character = (*it).toLatin1();
|
|
|
|
const DecorationButton button = buttonFromString(QByteArray::fromRawData(&character, 1));
|
|
|
|
if (button != DecorationButtonNone) {
|
|
|
|
ret << button;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
return buttonsFromString(config.readEntry(key, buttonsToString(defaultValue)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void KDecorationOptions::writeDecorationButtons(KConfigGroup &config, const char *key,
|
|
|
|
const QList< DecorationButton > &value)
|
|
|
|
{
|
|
|
|
initButtons();
|
|
|
|
config.writeEntry(key, buttonsToString(value));
|
|
|
|
}
|
|
|
|
|
2013-03-17 11:24:18 +00:00
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
int decoration_bridge_version()
|
|
|
|
{
|
|
|
|
return KWIN_DECORATION_BRIDGE_API_VERSION;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "kdecoration.moc"
|