2009-07-26 20:58:27 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Marco Martin <notmart@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 "windoweffects.h"
|
|
|
|
|
|
|
|
#include <QVarLengthArray>
|
|
|
|
|
2009-07-28 17:54:17 +02:00
|
|
|
#include <kwindowsystem.h>
|
2009-07-26 20:58:27 +02:00
|
|
|
|
2009-07-30 13:09:45 +02:00
|
|
|
#ifdef Q_WS_X11
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <QX11Info>
|
|
|
|
#endif
|
|
|
|
|
2009-07-26 20:58:27 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace WindowEffects
|
|
|
|
{
|
|
|
|
|
2009-07-28 03:33:31 +02:00
|
|
|
void slideWindow(WId id, Plasma::Location location, int offset)
|
2009-07-26 20:58:27 +02:00
|
|
|
{
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
Display *dpy = QX11Info::display();
|
|
|
|
Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False );
|
|
|
|
QVarLengthArray<long, 1024> data(2);
|
|
|
|
|
2009-07-27 23:53:36 +02:00
|
|
|
data[0] = offset;
|
|
|
|
|
2009-07-26 20:58:27 +02:00
|
|
|
switch (location) {
|
|
|
|
case LeftEdge:
|
|
|
|
data[1] = 0;
|
|
|
|
break;
|
|
|
|
case TopEdge:
|
|
|
|
data[1] = 1;
|
|
|
|
break;
|
|
|
|
case RightEdge:
|
|
|
|
data[1] = 2;
|
|
|
|
break;
|
|
|
|
case BottomEdge:
|
|
|
|
data[1] = 3;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (location == Desktop || location == Floating) {
|
|
|
|
XDeleteProperty(dpy, id, atom);
|
|
|
|
} else {
|
|
|
|
XChangeProperty(dpy, id, atom, atom, 32, PropModeReplace,
|
|
|
|
reinterpret_cast<unsigned char *>(data.data()), data.size());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-07-28 15:50:48 +02:00
|
|
|
void slideWindow(QWidget *widget, Plasma::Location location)
|
|
|
|
{
|
|
|
|
#ifdef Q_WS_X11
|
|
|
|
Display *dpy = QX11Info::display();
|
|
|
|
Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False );
|
|
|
|
QVarLengthArray<long, 1024> data(2);
|
|
|
|
|
|
|
|
switch (location) {
|
|
|
|
case LeftEdge:
|
|
|
|
data[0] = widget->geometry().left();
|
|
|
|
data[1] = 0;
|
|
|
|
break;
|
|
|
|
case TopEdge:
|
|
|
|
data[0] = widget->geometry().top();
|
|
|
|
data[1] = 1;
|
|
|
|
break;
|
|
|
|
case RightEdge:
|
|
|
|
data[0] = widget->geometry().right();
|
|
|
|
data[1] = 2;
|
|
|
|
break;
|
|
|
|
case BottomEdge:
|
|
|
|
data[0] = widget->geometry().bottom();
|
|
|
|
data[1] = 3;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (location == Desktop || location == Floating) {
|
|
|
|
XDeleteProperty(dpy, widget->effectiveWinId(), atom);
|
|
|
|
} else {
|
|
|
|
XChangeProperty(dpy, widget->effectiveWinId(), atom, atom, 32, PropModeReplace,
|
|
|
|
reinterpret_cast<unsigned char *>(data.data()), data.size());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-07-26 20:58:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|