2007-04-29 17:35:43 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
*
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "preview.h"
|
|
|
|
|
|
|
|
#include <kapplication.h>
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kglobal.h>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QStyle>
|
2009-08-25 11:13:27 +00:00
|
|
|
#include <QPainter>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QVector>
|
2007-09-01 19:45:04 +00:00
|
|
|
#include <kicon.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
|
|
|
|
#include <kdecorationfactory.h>
|
|
|
|
#include <kdecoration_plugins_p.h>
|
|
|
|
#include <QX11Info>
|
2009-07-31 15:38:12 +00:00
|
|
|
#include <kwindowsystem.h>
|
2010-04-23 19:20:01 +00:00
|
|
|
#include <QTextDocument>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KDecorationPreview::KDecorationPreview(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
options = new KDecorationPreviewOptions;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bridge[Active] = new KDecorationPreviewBridge(this, true);
|
|
|
|
bridge[Inactive] = new KDecorationPreviewBridge(this, false);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
deco[Active] = deco[Inactive] = NULL;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
no_preview = new QLabel(i18n("No preview available.\n"
|
|
|
|
"Most probably there\n"
|
|
|
|
"was a problem loading the plugin."), this);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
no_preview->setAlignment(Qt::AlignCenter);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
setMinimumSize(100, 100);
|
|
|
|
no_preview->resize(size());
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
KDecorationPreview::~KDecorationPreview()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i < NumWindows; i++) {
|
2007-04-29 17:35:43 +00:00
|
|
|
delete deco[i];
|
|
|
|
delete bridge[i];
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
delete options;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool KDecorationPreview::recreateDecoration(KDecorationPlugins* plugins)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < NumWindows; i++) {
|
2007-04-29 17:35:43 +00:00
|
|
|
delete deco[i]; // deletes also window
|
2011-01-30 14:34:42 +00:00
|
|
|
deco[i] = plugins->createDecoration(bridge[i]);
|
2007-04-29 17:35:43 +00:00
|
|
|
deco[i]->init();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (deco[Active] == NULL || deco[Inactive] == NULL) {
|
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
|
|
|
|
|
|
|
positionPreviews();
|
2009-06-26 01:53:38 +00:00
|
|
|
//deco[Inactive]->widget()->show();
|
|
|
|
//deco[Active]->widget()->show();
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-06-26 01:53:38 +00:00
|
|
|
//deco[Inactive]->widget()->render( this, deco[Inactive]->widget()->mapToParent( QPoint(0,0) ) );
|
2010-05-02 20:25:27 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreview::enablePreview()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
no_preview->hide();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreview::disablePreview()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete deco[Active];
|
|
|
|
delete deco[Inactive];
|
|
|
|
deco[Active] = deco[Inactive] = NULL;
|
|
|
|
no_preview->show();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-07-25 07:58:27 +00:00
|
|
|
KDecorationFactory *KDecorationPreview::factory() const
|
|
|
|
{
|
|
|
|
return deco[Active] ? deco[Active]->factory() : 0;
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreview::paintEvent(QPaintEvent* e)
|
|
|
|
{
|
|
|
|
Q_UNUSED(e);
|
|
|
|
QPainter painter(this);
|
|
|
|
QPoint delta = mapTo(window(), QPoint(0, 0));
|
2009-09-02 14:30:30 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (deco[Inactive]) {
|
2009-09-02 14:30:30 +00:00
|
|
|
QWidget *w = deco[Inactive]->widget();
|
2011-01-30 14:34:42 +00:00
|
|
|
w->render(&painter, delta + w->mapToParent(QPoint(0, 0)));
|
|
|
|
}
|
|
|
|
if (deco[Active]) {
|
2009-09-02 14:30:30 +00:00
|
|
|
QWidget *w = deco[Active]->widget();
|
2011-01-30 14:34:42 +00:00
|
|
|
w->render(&painter, delta + w->mapToParent(QPoint(0, 0)));
|
2009-08-25 11:13:27 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-06-26 01:53:38 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QPixmap KDecorationPreview::preview(QTextDocument* document, QWidget* widget)
|
|
|
|
{
|
|
|
|
Q_UNUSED(document);
|
|
|
|
Q_UNUSED(widget);
|
|
|
|
QPixmap pixmap(size());
|
|
|
|
pixmap.fill(Qt::transparent);
|
2010-01-19 13:44:22 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (deco[Inactive]) {
|
2010-01-19 13:44:22 +00:00
|
|
|
QWidget *w = deco[Inactive]->widget();
|
2011-01-30 14:34:42 +00:00
|
|
|
w->render(&pixmap, w->mapToParent(QPoint(0, 0)));
|
|
|
|
}
|
|
|
|
if (deco[Active]) {
|
2010-01-19 13:44:22 +00:00
|
|
|
QWidget *w = deco[Active]->widget();
|
2011-01-30 14:34:42 +00:00
|
|
|
w->render(&pixmap, w->mapToParent(QPoint(0, 0)));
|
2010-01-19 13:44:22 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return pixmap;
|
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreview::resizeEvent(QResizeEvent* e)
|
|
|
|
{
|
|
|
|
QWidget::resizeEvent(e);
|
2007-04-29 17:35:43 +00:00
|
|
|
positionPreviews();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreview::positionPreviews()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
int titleBarHeight, leftBorder, rightBorder, xoffset,
|
|
|
|
dummy1, dummy2, dummy3;
|
|
|
|
QRect geometry;
|
|
|
|
QSize size;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
no_preview->resize(this->size());
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!deco[Active] || !deco[Inactive])
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// don't have more than one reference to the same dummy variable in one borders() call.
|
2011-01-30 14:34:42 +00:00
|
|
|
deco[Active]->borders(dummy1, dummy2, titleBarHeight, dummy3);
|
|
|
|
deco[Inactive]->borders(leftBorder, rightBorder, dummy1, dummy2);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
titleBarHeight = qMin(int(titleBarHeight * .9), 30);
|
|
|
|
xoffset = qMin(qMax(10, QApplication::isRightToLeft()
|
|
|
|
? leftBorder : rightBorder), 30);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Resize the active window
|
2011-01-30 14:34:42 +00:00
|
|
|
size = QSize(width() - xoffset, height() - titleBarHeight)
|
|
|
|
.expandedTo(deco[Active]->minimumSize());
|
|
|
|
geometry = QRect(QPoint(0, titleBarHeight), size);
|
2009-07-31 15:38:12 +00:00
|
|
|
if (KDecorationUnstable *unstable = qobject_cast<KDecorationUnstable *>(deco[Active])) {
|
|
|
|
int padLeft, padRight, padTop, padBottom;
|
|
|
|
unstable->padding(padLeft, padRight, padTop, padBottom);
|
|
|
|
geometry.adjust(-padLeft, -padTop, padRight, padBottom);
|
|
|
|
}
|
|
|
|
geometry.adjust(10, 10, -10, -10);
|
2011-01-30 14:34:42 +00:00
|
|
|
deco[Active]->widget()->setGeometry(QStyle::visualRect(this->layoutDirection(), this->rect(), geometry));
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Resize the inactive window
|
2011-01-30 14:34:42 +00:00
|
|
|
size = QSize(width() - xoffset, height() - titleBarHeight)
|
|
|
|
.expandedTo(deco[Inactive]->minimumSize());
|
|
|
|
geometry = QRect(QPoint(xoffset, 0), size);
|
2009-07-31 15:38:12 +00:00
|
|
|
if (KDecorationUnstable *unstable = qobject_cast<KDecorationUnstable *>(deco[Inactive])) {
|
|
|
|
int padLeft, padRight, padTop, padBottom;
|
|
|
|
unstable->padding(padLeft, padRight, padTop, padBottom);
|
|
|
|
geometry.adjust(-padLeft, -padTop, padRight, padBottom);
|
|
|
|
}
|
|
|
|
geometry.adjust(10, 10, -10, -10);
|
2011-01-30 14:34:42 +00:00
|
|
|
deco[Inactive]->widget()->setGeometry(QStyle::visualRect(this->layoutDirection(), this->rect(), geometry));
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreview::setPreviewMask(const QRegion& reg, int mode, bool active)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QWidget *widget = active ? deco[Active]->widget() : deco[Inactive]->widget();
|
|
|
|
|
|
|
|
// FRAME duped from client.cpp
|
2011-01-30 14:34:42 +00:00
|
|
|
if (mode == Unsorted) {
|
|
|
|
XShapeCombineRegion(QX11Info::display(), widget->winId(), ShapeBounding, 0, 0,
|
|
|
|
reg.handle(), ShapeSet);
|
|
|
|
} else {
|
2007-04-29 17:35:43 +00:00
|
|
|
QVector< QRect > rects = reg.rects();
|
2011-01-30 14:34:42 +00:00
|
|
|
XRectangle* xrects = new XRectangle[ rects.count()];
|
|
|
|
for (int i = 0;
|
|
|
|
i < rects.count();
|
|
|
|
++i) {
|
2007-04-29 17:35:43 +00:00
|
|
|
xrects[ i ].x = rects[ i ].x();
|
|
|
|
xrects[ i ].y = rects[ i ].y();
|
|
|
|
xrects[ i ].width = rects[ i ].width();
|
|
|
|
xrects[ i ].height = rects[ i ].height();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
XShapeCombineRectangles(QX11Info::display(), widget->winId(), ShapeBounding, 0, 0,
|
|
|
|
xrects, rects.count(), ShapeSet, mode);
|
|
|
|
delete[] xrects;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (active)
|
|
|
|
mask = reg; // keep shape of the active window for unobscuredRegion()
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect KDecorationPreview::windowGeometry(bool active) const
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QWidget *widget = active ? deco[Active]->widget() : deco[Inactive]->widget();
|
|
|
|
return widget->geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreview::setTempBorderSize(KDecorationPlugins* plugin, KDecorationDefines::BorderSize size)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
options->setCustomBorderSize(size);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (plugin->factory()->reset(KDecorationDefines::SettingBorder)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
// can't handle the change, recreate decorations then
|
|
|
|
recreateDecoration(plugin);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2007-04-29 17:35:43 +00:00
|
|
|
// handles the update, only update position...
|
|
|
|
positionPreviews();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreview::setTempButtons(KDecorationPlugins* plugin, bool customEnabled, const QString &left, const QString &right)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
options->setCustomTitleButtonsEnabled(customEnabled);
|
|
|
|
options->setCustomTitleButtons(left, right);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (plugin->factory()->reset(KDecorationDefines::SettingButtons)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
// can't handle the change, recreate decorations then
|
|
|
|
recreateDecoration(plugin);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2007-04-29 17:35:43 +00:00
|
|
|
// handles the update, only update position...
|
|
|
|
positionPreviews();
|
|
|
|
}
|
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 KDecorationPreview::unobscuredRegion(bool active, const QRegion& r) const
|
|
|
|
{
|
|
|
|
if (active) // this one is not obscured
|
2007-04-29 17:35:43 +00:00
|
|
|
return r;
|
2011-01-30 14:34:42 +00:00
|
|
|
else {
|
2007-04-29 17:35:43 +00:00
|
|
|
// copied from KWin core's code
|
|
|
|
QRegion ret = r;
|
|
|
|
QRegion r2 = mask;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (r2.isEmpty())
|
|
|
|
r2 = QRegion(windowGeometry(true));
|
|
|
|
r2.translate(windowGeometry(true).x() - windowGeometry(false).x(),
|
|
|
|
windowGeometry(true).y() - windowGeometry(false).y());
|
2007-04-29 17:35:43 +00:00
|
|
|
ret -= r2;
|
|
|
|
return ret;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KDecorationPreviewBridge::KDecorationPreviewBridge(KDecorationPreview* p, bool a)
|
|
|
|
: preview(p), active(a)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QWidget* KDecorationPreviewBridge::initialParentWidget() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return preview;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Qt::WFlags KDecorationPreviewBridge::initialWFlags() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isActive() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return active;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isCloseable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isMaximizable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
KDecoration::MaximizeMode KDecorationPreviewBridge::maximizeMode() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return KDecoration::MaximizeRestore;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isMinimizable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::providesContextHelp() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int KDecorationPreviewBridge::desktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return 1;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isModal() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
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
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isShadeable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isShade() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
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
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isSetShade() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
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
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::keepAbove() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
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
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::keepBelow() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
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
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isMovable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isResizable() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
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 KDecorationPreviewBridge::windowType(unsigned long) const
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return NET::Normal;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QIcon KDecorationPreviewBridge::icon() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return KIcon("xorg");
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QString KDecorationPreviewBridge::caption() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return active ? i18n("Active Window") : i18n("Inactive Window");
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreviewBridge::processMousePressEvent(QMouseEvent*)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreviewBridge::showWindowMenu(const QRect &)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreviewBridge::showWindowMenu(const QPoint &)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreviewBridge::performWindowOperation(WindowOperation)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreviewBridge::setMask(const QRegion& reg, int mode)
|
|
|
|
{
|
|
|
|
preview->setPreviewMask(reg, mode, active);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
bool KDecorationPreviewBridge::isPreview() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QRect KDecorationPreviewBridge::geometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
return preview->windowGeometry(active);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
QRect KDecorationPreviewBridge::iconGeometry() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return QRect();
|
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 KDecorationPreviewBridge::unobscuredRegion(const QRegion& r) const
|
|
|
|
{
|
|
|
|
return preview->unobscuredRegion(active, r);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
WId KDecorationPreviewBridge::windowId() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return 0; // no decorated window
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreviewBridge::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 KDecorationPreviewBridge::maximize(MaximizeMode)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreviewBridge::minimize()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreviewBridge::showContextHelp()
|
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 KDecorationPreviewBridge::setDesktop(int)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreviewBridge::titlebarDblClickOperation()
|
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 KDecorationPreviewBridge::titlebarMouseWheelOperation(int)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreviewBridge::setShade(bool)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreviewBridge::setKeepAbove(bool)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KDecorationPreviewBridge::setKeepBelow(bool)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
int KDecorationPreviewBridge::currentDesktop() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return 1;
|
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 KDecorationPreviewBridge::grabXServer(bool)
|
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-10-17 10:30:43 +00:00
|
|
|
bool KDecorationPreviewBridge::compositingActive() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-07-31 15:38:12 +00:00
|
|
|
return KWindowSystem::compositingActive();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-10-17 10:30:43 +00:00
|
|
|
|
2009-11-25 23:32:35 +00:00
|
|
|
QRect KDecorationPreviewBridge::transparentRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-25 23:32:35 +00:00
|
|
|
return QRect();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-25 23:32:35 +00:00
|
|
|
|
2009-11-15 03:24:04 +00:00
|
|
|
// Window tabbing
|
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
int KDecorationPreviewBridge::tabCount() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString KDecorationPreviewBridge::caption(int) const
|
|
|
|
{
|
|
|
|
return active ? "Active Window" : "Inactive Window";
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
QIcon KDecorationPreviewBridge::icon(int) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-01-12 06:42:55 +00:00
|
|
|
return icon();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
long KDecorationPreviewBridge::tabId(int) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
return 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
long KDecorationPreviewBridge::currentTabId() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
return 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KDecorationPreviewBridge::setCurrentTab(long)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KDecorationPreviewBridge::tab_A_before_B(long, long)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KDecorationPreviewBridge::tab_A_behind_B(long, long)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KDecorationPreviewBridge::untab(long, const QRect&)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KDecorationPreviewBridge::closeTab(long)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KDecorationPreviewBridge::closeTabGroup()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
void KDecorationPreviewBridge::showWindowMenu(const QPoint &, long)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KDecoration::WindowOperation KDecorationPreviewBridge::buttonToWindowOperation(Qt::MouseButtons)
|
|
|
|
{
|
2009-11-17 07:17:49 +00:00
|
|
|
return KDecoration::NoOp;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
KDecorationPreviewOptions::KDecorationPreviewOptions()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
customBorderSize = BordersCount; // invalid
|
|
|
|
customButtonsChanged = false; // invalid
|
|
|
|
customButtons = true;
|
|
|
|
customTitleButtonsLeft.clear(); // invalid
|
|
|
|
customTitleButtonsRight.clear(); // invalid
|
|
|
|
updateSettings();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
KDecorationPreviewOptions::~KDecorationPreviewOptions()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
unsigned long KDecorationPreviewOptions::updateSettings()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
KConfig cfg("kwinrc");
|
2007-04-29 17:35:43 +00:00
|
|
|
unsigned long changed = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
changed |= KDecorationOptions::updateSettings(&cfg);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// set custom border size/buttons
|
|
|
|
if (customBorderSize != BordersCount)
|
2011-01-30 14:34:42 +00:00
|
|
|
setBorderSize(customBorderSize);
|
2007-04-29 17:35:43 +00:00
|
|
|
if (customButtonsChanged)
|
2011-01-30 14:34:42 +00:00
|
|
|
setCustomButtonPositions(customButtons);
|
2007-04-29 17:35:43 +00:00
|
|
|
if (customButtons) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!customTitleButtonsLeft.isNull())
|
|
|
|
setTitleButtonsLeft(customTitleButtonsLeft);
|
|
|
|
if (!customTitleButtonsRight.isNull())
|
|
|
|
setTitleButtonsRight(customTitleButtonsRight);
|
2007-04-29 17:35:43 +00:00
|
|
|
} else {
|
2011-01-30 14:34:42 +00:00
|
|
|
setTitleButtonsLeft(KDecorationOptions::defaultTitleButtonsLeft());
|
|
|
|
setTitleButtonsRight(KDecorationOptions::defaultTitleButtonsRight());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return changed;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreviewOptions::setCustomBorderSize(BorderSize size)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
customBorderSize = size;
|
|
|
|
|
|
|
|
updateSettings();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void KDecorationPreviewOptions::setCustomTitleButtonsEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
customButtonsChanged = true;
|
|
|
|
customButtons = enabled;
|
|
|
|
|
|
|
|
updateSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KDecorationPreviewOptions::setCustomTitleButtons(const QString &left, const QString &right)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
customTitleButtonsLeft = left;
|
|
|
|
customTitleButtonsRight = right;
|
|
|
|
|
|
|
|
updateSettings();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool KDecorationPreviewPlugins::provides(Requirement)
|
|
|
|
{
|
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
|
|
|
|
|
|
|
#include "preview.moc"
|