windowpreviews/windowshadows don't go here anymore
will be qml bindings material
This commit is contained in:
parent
988f3edcc8
commit
ec45134bf8
@ -109,8 +109,6 @@ set(plasma_LIB_SRCS
|
|||||||
private/serviceprovider.cpp
|
private/serviceprovider.cpp
|
||||||
private/storage.cpp
|
private/storage.cpp
|
||||||
private/storagethread.cpp
|
private/storagethread.cpp
|
||||||
private/windowpreview.cpp
|
|
||||||
private/windowshadows.cpp
|
|
||||||
private/applet_p.cpp
|
private/applet_p.cpp
|
||||||
private/containment_p.cpp
|
private/containment_p.cpp
|
||||||
|
|
||||||
|
@ -1,227 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2007 by Dan Meltzer <hydrogen@notyetimplemented.com>
|
|
||||||
* Copyright (C) 2008 by Alexis Ménard <darktears31@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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 "windowpreview_p.h"
|
|
||||||
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QVarLengthArray>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
|
|
||||||
#include <kwindoweffects.h>
|
|
||||||
#include <kwindowsystem.h>
|
|
||||||
#include <kdebug.h>
|
|
||||||
|
|
||||||
#include <plasma/framesvg.h>
|
|
||||||
|
|
||||||
namespace Plasma {
|
|
||||||
|
|
||||||
WindowPreview::WindowPreview(QWidget *parent)
|
|
||||||
: QWidget(parent),
|
|
||||||
m_highlightWindows(false)
|
|
||||||
{
|
|
||||||
m_background = new Plasma::FrameSvg(this);
|
|
||||||
m_background->setImagePath("widgets/frame");
|
|
||||||
m_background->setElementPrefix("raised");
|
|
||||||
setMouseTracking(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowPreview::setWindowIds(const QList<WId> wids)
|
|
||||||
{
|
|
||||||
if (!KWindowEffects::isEffectAvailable(KWindowEffects::WindowPreview)) {
|
|
||||||
setMinimumSize(0,0);
|
|
||||||
setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
|
||||||
ids.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIXME: need to get rid of this 4 window maximum by using a smarter layout
|
|
||||||
if (wids.count() < 5) {
|
|
||||||
ids = wids;
|
|
||||||
} else {
|
|
||||||
ids = wids.mid(0, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
windowSizes = KWindowEffects::windowSizes(ids);
|
|
||||||
QSize s(sizeHint());
|
|
||||||
if (s.isValid()) {
|
|
||||||
setFixedSize(sizeHint());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<WId> WindowPreview::windowIds() const
|
|
||||||
{
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize WindowPreview::sizeHint() const
|
|
||||||
{
|
|
||||||
if (ids.size() == 0) {
|
|
||||||
return QSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!windowSizes.size() == 0) {
|
|
||||||
windowSizes = KWindowEffects::windowSizes(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
int maxHeight = 0;
|
|
||||||
int totalWidth = 0;
|
|
||||||
|
|
||||||
foreach (const QSize &s, windowSizes) {
|
|
||||||
if (s.height() > maxHeight) {
|
|
||||||
maxHeight = s.height();
|
|
||||||
}
|
|
||||||
|
|
||||||
totalWidth += s.width();
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize s(totalWidth, maxHeight);
|
|
||||||
|
|
||||||
qreal left, top, right, bottom;
|
|
||||||
m_background->getMargins(left, top, right, bottom);
|
|
||||||
|
|
||||||
s.scale(WINDOW_WIDTH*windowSizes.size(), WINDOW_HEIGHT, Qt::KeepAspectRatio);
|
|
||||||
s = s + QSize(left+right+WINDOW_MARGIN*(windowSizes.size()-1), top+bottom);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool WindowPreview::isEmpty() const
|
|
||||||
{
|
|
||||||
foreach (WId id, ids) {
|
|
||||||
if (id != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WindowPreview::setHighlightWindows(const bool highlight)
|
|
||||||
{
|
|
||||||
m_highlightWindows = highlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WindowPreview::highlightWindows() const
|
|
||||||
{
|
|
||||||
return m_highlightWindows;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowPreview::setInfo()
|
|
||||||
{
|
|
||||||
QWidget *w = parentWidget();
|
|
||||||
if (isEmpty()) {
|
|
||||||
KWindowEffects::showWindowThumbnails(w->winId());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowSizes.size() == 0) {
|
|
||||||
windowSizes = KWindowEffects::windowSizes(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (windowSizes.size() == 0) {
|
|
||||||
KWindowEffects::showWindowThumbnails(w->winId());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_ASSERT(w->isWindow()); // parent must be toplevel
|
|
||||||
|
|
||||||
QSize thumbnailSize = sizeHint();
|
|
||||||
thumbnailSize.scale(size(), Qt::KeepAspectRatio);
|
|
||||||
m_background->resizeFrame(thumbnailSize);
|
|
||||||
|
|
||||||
qreal left, top, right, bottom;
|
|
||||||
m_background->getMargins(left, top, right, bottom);
|
|
||||||
const QRect thumbnailRect(QPoint(left, top), size() - QSize(left + right, top + bottom));
|
|
||||||
const int numWindows = ids.size();
|
|
||||||
const qreal thumbWidth = (thumbnailRect.width() - WINDOW_MARGIN*(numWindows - 1)) / numWindows;
|
|
||||||
|
|
||||||
// we paint in parent coords, but accept events in local coords
|
|
||||||
QList<QRect> inParentCoords;
|
|
||||||
m_thumbnailRects.clear();
|
|
||||||
|
|
||||||
int x = thumbnailRect.x();
|
|
||||||
foreach (QSize s, windowSizes) {
|
|
||||||
s.scale(thumbWidth, thumbnailRect.height(), Qt::KeepAspectRatio);
|
|
||||||
int y = thumbnailRect.y() + (thumbnailRect.height() - s.height())/2;
|
|
||||||
m_thumbnailRects.append(QRect(QPoint(x, y), s));
|
|
||||||
inParentCoords.append(QRect(mapToParent(QPoint(x, y)), s));
|
|
||||||
x += s.width() + WINDOW_MARGIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
KWindowEffects::showWindowThumbnails(w->winId(), ids, inParentCoords);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowPreview::paintEvent(QPaintEvent *e)
|
|
||||||
{
|
|
||||||
Q_UNUSED(e)
|
|
||||||
|
|
||||||
QPainter painter(this);
|
|
||||||
|
|
||||||
qreal left, top, right, bottom;
|
|
||||||
m_background->getMargins(left, top, right, bottom);
|
|
||||||
const QSize delta(left + right, top + bottom);
|
|
||||||
const QPoint topLeft(left, top);
|
|
||||||
|
|
||||||
foreach (const QRect &r, m_thumbnailRects) {
|
|
||||||
//kWarning()<<r;
|
|
||||||
m_background->resizeFrame(r.size() + delta);
|
|
||||||
m_background->paintFrame(&painter, r.topLeft() - topLeft);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowPreview::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < m_thumbnailRects.size(); ++i) {
|
|
||||||
if (m_thumbnailRects[i].contains(event->pos())) {
|
|
||||||
emit windowPreviewClicked(ids[i], event->buttons(), event->modifiers(), event->globalPos());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowPreview::mouseMoveEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (!m_highlightWindows) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < m_thumbnailRects.size(); ++i) {
|
|
||||||
if (m_thumbnailRects[i].contains(event->pos())) {
|
|
||||||
KWindowEffects::highlightWindows(effectiveWinId(), QList<WId>() << effectiveWinId() << ids[i]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
KWindowEffects::highlightWindows(effectiveWinId(), QList<WId>());
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowPreview::leaveEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
Q_UNUSED(event)
|
|
||||||
if (!m_highlightWindows) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
KWindowEffects::highlightWindows(effectiveWinId(), QList<WId>());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#include "moc_windowpreview_p.cpp"
|
|
@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2007 by Dan Meltzer <hydrogen@notyetimplemented.com>
|
|
||||||
* Copyright (C) 2008 by Alexis Ménard <darktears31@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PLASMA_WINDOWPREVIEW_P_H
|
|
||||||
#define PLASMA_WINDOWPREVIEW_P_H
|
|
||||||
|
|
||||||
#include <QWidget> // base class
|
|
||||||
#include <QSize> // stack allocated
|
|
||||||
|
|
||||||
namespace Plasma {
|
|
||||||
|
|
||||||
class FrameSvg;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*
|
|
||||||
* A widget which reserves area for window preview and sets hints on the toplevel
|
|
||||||
* tooltip widget that tells KWin to render the preview in this area. This depends
|
|
||||||
* on KWin's TaskbarThumbnail compositing effect (which is automatically detected).
|
|
||||||
*/
|
|
||||||
class WindowPreview : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
static bool previewsAvailable();
|
|
||||||
|
|
||||||
WindowPreview(QWidget *parent = 0);
|
|
||||||
|
|
||||||
void setWindowIds(const QList<WId> w);
|
|
||||||
QList<WId> windowIds() const;
|
|
||||||
void setInfo();
|
|
||||||
bool isEmpty() const;
|
|
||||||
virtual QSize sizeHint() const;
|
|
||||||
void setHighlightWindows(const bool highlight);
|
|
||||||
bool highlightWindows() const;
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void windowPreviewClicked(WId wid, Qt::MouseButtons buttons, Qt::KeyboardModifiers keys, const QPoint &screenPos);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *e);
|
|
||||||
void mousePressEvent(QMouseEvent *event);
|
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
|
||||||
void leaveEvent(QEvent *event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
QList<WId> ids;
|
|
||||||
mutable QList<QSize> windowSizes;
|
|
||||||
QList <QRect> m_thumbnailRects;
|
|
||||||
FrameSvg *m_background;
|
|
||||||
bool m_highlightWindows;
|
|
||||||
|
|
||||||
static const int WINDOW_MARGIN = 10;
|
|
||||||
static const int WINDOW_WIDTH = 200;
|
|
||||||
static const int WINDOW_HEIGHT = 150;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#endif // PLASMA_WINDOWPREVIEW_P_H
|
|
||||||
|
|
@ -1,241 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011 by Aaron Seigo <aseigo@kde.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License version 2,
|
|
||||||
* 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 Library 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 "windowshadows_p.h"
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QPainter>
|
|
||||||
|
|
||||||
#include <config-plasma.h>
|
|
||||||
|
|
||||||
#if HAVE_X11
|
|
||||||
#pragma message("X11 Pixmap code disabled, X11 <=> Qt pixmap conversion code not available in Qt 5.0")
|
|
||||||
#undef HAVE_X11
|
|
||||||
#define HAVE_X11 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_X11
|
|
||||||
#include <QX11Info>
|
|
||||||
#include <X11/Xatom.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <fixx11h.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class WindowShadows::Private
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Private(WindowShadows *shadows)
|
|
||||||
: q(shadows),
|
|
||||||
m_managePixmaps(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
~Private()
|
|
||||||
{
|
|
||||||
clearPixmaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearPixmaps();
|
|
||||||
void setupPixmaps();
|
|
||||||
void initPixmap(const QString &element);
|
|
||||||
void updateShadow(const QWidget *window);
|
|
||||||
void clearShadow(const QWidget *window);
|
|
||||||
void updateShadows();
|
|
||||||
void windowDestroyed(QObject *deletedObject);
|
|
||||||
|
|
||||||
WindowShadows *q;
|
|
||||||
QList<QPixmap> m_shadowPixmaps;
|
|
||||||
QVector<unsigned long> m_data;
|
|
||||||
QSet<const QWidget *> m_windows;
|
|
||||||
bool m_managePixmaps;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WindowShadowsSingleton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WindowShadows self;
|
|
||||||
};
|
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(WindowShadowsSingleton, privateWindowShadowsSelf)
|
|
||||||
|
|
||||||
WindowShadows *WindowShadows::self()
|
|
||||||
{
|
|
||||||
return &privateWindowShadowsSelf()->self;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowShadows::WindowShadows(QObject *parent)
|
|
||||||
: Plasma::Svg(parent),
|
|
||||||
d(new Private(this))
|
|
||||||
{
|
|
||||||
setImagePath("dialogs/background");
|
|
||||||
connect(this, SIGNAL(repaintNeeded()), this, SLOT(updateShadows()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowShadows::addWindow(const QWidget *window)
|
|
||||||
{
|
|
||||||
if (!window || !window->isWindow()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->m_windows << window;
|
|
||||||
d->updateShadow(window);
|
|
||||||
connect(window, SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed(QObject*)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowShadows::removeWindow(const QWidget *window)
|
|
||||||
{
|
|
||||||
if (!d->m_windows.contains(window)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->m_windows.remove(window);
|
|
||||||
disconnect(window, 0, this, 0);
|
|
||||||
d->clearShadow(window);
|
|
||||||
|
|
||||||
if (d->m_windows.isEmpty()) {
|
|
||||||
d->clearPixmaps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowShadows::Private::windowDestroyed(QObject *deletedObject)
|
|
||||||
{
|
|
||||||
m_windows.remove(static_cast<QWidget *>(deletedObject));
|
|
||||||
|
|
||||||
if (m_windows.isEmpty()) {
|
|
||||||
clearPixmaps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowShadows::Private::updateShadows()
|
|
||||||
{
|
|
||||||
setupPixmaps();
|
|
||||||
foreach (const QWidget *window, m_windows) {
|
|
||||||
updateShadow(window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowShadows::Private::initPixmap(const QString &element)
|
|
||||||
{
|
|
||||||
#if HAVE_X11
|
|
||||||
QPixmap pix = q->pixmap(element);
|
|
||||||
if (pix.handle() == 0) {
|
|
||||||
Pixmap xPix = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), pix.width(), pix.height(), 32);
|
|
||||||
QPixmap tempPix = QPixmap::fromX11Pixmap(xPix, QPixmap::ExplicitlyShared);
|
|
||||||
tempPix.fill(Qt::transparent);
|
|
||||||
QPainter p(&tempPix);
|
|
||||||
p.drawPixmap(QPoint(0, 0), pix);
|
|
||||||
m_shadowPixmaps << tempPix;
|
|
||||||
m_managePixmaps = true;
|
|
||||||
} else {
|
|
||||||
m_shadowPixmaps << pix;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowShadows::Private::setupPixmaps()
|
|
||||||
{
|
|
||||||
clearPixmaps();
|
|
||||||
initPixmap("shadow-top");
|
|
||||||
initPixmap("shadow-topright");
|
|
||||||
initPixmap("shadow-right");
|
|
||||||
initPixmap("shadow-bottomright");
|
|
||||||
initPixmap("shadow-bottom");
|
|
||||||
initPixmap("shadow-bottomleft");
|
|
||||||
initPixmap("shadow-left");
|
|
||||||
initPixmap("shadow-topleft");
|
|
||||||
|
|
||||||
#if HAVE_X11
|
|
||||||
foreach (const QPixmap &pixmap, m_shadowPixmaps) {
|
|
||||||
m_data << pixmap.handle();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QSize marginHint = q->elementSize("shadow-hint-top-margin");
|
|
||||||
if (marginHint.isValid()) {
|
|
||||||
m_data << marginHint.height();
|
|
||||||
} else {
|
|
||||||
m_data << m_shadowPixmaps[0].height(); // top
|
|
||||||
}
|
|
||||||
|
|
||||||
marginHint = q->elementSize("shadow-hint-right-margin");
|
|
||||||
if (marginHint.isValid()) {
|
|
||||||
m_data << marginHint.width();
|
|
||||||
} else {
|
|
||||||
m_data << m_shadowPixmaps[2].width(); // right
|
|
||||||
}
|
|
||||||
|
|
||||||
marginHint = q->elementSize("shadow-hint-bottom-margin");
|
|
||||||
if (marginHint.isValid()) {
|
|
||||||
m_data << marginHint.height();
|
|
||||||
} else {
|
|
||||||
m_data << m_shadowPixmaps[4].height(); // bottom
|
|
||||||
}
|
|
||||||
|
|
||||||
marginHint = q->elementSize("shadow-hint-left-margin");
|
|
||||||
if (marginHint.isValid()) {
|
|
||||||
m_data << marginHint.width();
|
|
||||||
} else {
|
|
||||||
m_data << m_shadowPixmaps[6].width(); // left
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowShadows::Private::clearPixmaps()
|
|
||||||
{
|
|
||||||
#if HAVE_X11
|
|
||||||
if (m_managePixmaps) {
|
|
||||||
foreach (const QPixmap &pixmap, m_shadowPixmaps) {
|
|
||||||
XFreePixmap(QX11Info::display(), pixmap.handle());
|
|
||||||
}
|
|
||||||
m_managePixmaps = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
m_shadowPixmaps.clear();
|
|
||||||
m_data.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowShadows::Private::updateShadow(const QWidget *window)
|
|
||||||
{
|
|
||||||
#if HAVE_X11
|
|
||||||
if (m_data.isEmpty()) {
|
|
||||||
setupPixmaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
Display *dpy = QX11Info::display();
|
|
||||||
Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False);
|
|
||||||
|
|
||||||
//kDebug() << "going to set the shadow of" << winId() << "to" << data;
|
|
||||||
XChangeProperty(dpy, window->winId(), atom, XA_CARDINAL, 32, PropModeReplace,
|
|
||||||
reinterpret_cast<const unsigned char *>(m_data.constData()), m_data.size());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowShadows::Private::clearShadow(const QWidget *window)
|
|
||||||
{
|
|
||||||
#if HAVE_X11
|
|
||||||
Display *dpy = QX11Info::display();
|
|
||||||
Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False);
|
|
||||||
XDeleteProperty(dpy, window->winId(), atom);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#include "moc_windowshadows_p.cpp"
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011 by Aaron Seigo <aseigo@kde.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Library General Public License version 2,
|
|
||||||
* 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 Library 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PLASMA_WINDOWSHADOWS_H
|
|
||||||
#define PLASMA_WINDOWSHADOWS_H
|
|
||||||
|
|
||||||
#include <QSet>
|
|
||||||
|
|
||||||
#include <plasma/svg.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class WindowShadows : Plasma::Svg
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
static WindowShadows *self();
|
|
||||||
|
|
||||||
explicit WindowShadows(QObject *parent = 0);
|
|
||||||
|
|
||||||
void addWindow(const QWidget *window);
|
|
||||||
void removeWindow(const QWidget *window);
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
Private * const d;
|
|
||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void updateShadows())
|
|
||||||
Q_PRIVATE_SLOT(d, void windowDestroyed(QObject *deletedObject))
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user