WindowEffects namespace: here will go functions used to set atoms on
windows to trigger kwin effects, without having t use xlibs directly from the rest of the code svn path=/trunk/KDE/kdelibs/; revision=1002670
This commit is contained in:
parent
2b543937ab
commit
6a60d6cf75
@ -103,6 +103,7 @@ set(plasma_LIB_SRCS
|
||||
version.cpp
|
||||
view.cpp
|
||||
wallpaper.cpp
|
||||
windoweffects.cpp
|
||||
widgets/checkbox.cpp
|
||||
widgets/combobox.cpp
|
||||
widgets/flashinglabel.cpp
|
||||
@ -211,6 +212,7 @@ set(plasma_LIB_INCLUDES
|
||||
extendergroup.h
|
||||
extenderitem.h
|
||||
paintutils.h
|
||||
windoweffects.h
|
||||
framesvg.h
|
||||
plasma.h
|
||||
plasma_export.h
|
||||
|
84
dialog.cpp
84
dialog.cpp
@ -49,6 +49,7 @@
|
||||
#include "plasma/private/extender_p.h"
|
||||
#include "plasma/framesvg.h"
|
||||
#include "plasma/theme.h"
|
||||
#include "plasma/windoweffects.h"
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <X11/Xlib.h>
|
||||
@ -526,6 +527,19 @@ void Dialog::showEvent(QShowEvent * event)
|
||||
emit dialogVisible(true);
|
||||
}
|
||||
|
||||
void Dialog::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
if (d->view) {
|
||||
d->view->setFocus();
|
||||
}
|
||||
|
||||
if (d->graphicsWidget) {
|
||||
d->graphicsWidget->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog::moveEvent(QMoveEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
@ -559,37 +573,26 @@ void Dialog::animatedHide(Plasma::Direction direction)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
//set again the atom, the location could have changed
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
QRect avail = desktop->availableGeometry(desktop->screenNumber(pos()));
|
||||
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False );
|
||||
QVarLengthArray<long, 1024> data(2);
|
||||
Location location = Desktop;
|
||||
|
||||
switch (direction) {
|
||||
case Left:
|
||||
data[0] = avail.left();
|
||||
data[1] = 0;
|
||||
break;
|
||||
case Up:
|
||||
data[0] = avail.top();
|
||||
data[1] = 1;
|
||||
case Down:
|
||||
location = BottomEdge;
|
||||
break;
|
||||
case Right:
|
||||
data[0] = avail.right();
|
||||
data[1] = 2;
|
||||
location = RightEdge;
|
||||
break;
|
||||
case Left:
|
||||
location = LeftEdge;
|
||||
break;
|
||||
case Up:
|
||||
location = TopEdge;
|
||||
break;
|
||||
case Down:
|
||||
default:
|
||||
data[0] = avail.bottom();
|
||||
data[1] = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
XChangeProperty(dpy, winId(), atom, atom, 32, PropModeReplace,
|
||||
reinterpret_cast<unsigned char *>(data.data()), data.size());
|
||||
#endif
|
||||
Plasma::WindowEffects::setSlidingWindow(winId(), location);
|
||||
|
||||
hide();
|
||||
}
|
||||
@ -601,36 +604,27 @@ void Dialog::animatedShow(Plasma::Direction direction)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
QRect avail = desktop->availableGeometry(desktop->screenNumber(pos()));
|
||||
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False );
|
||||
QVarLengthArray<long, 1024> data(2);
|
||||
//copied to not add new api
|
||||
Location location = Desktop;
|
||||
|
||||
switch (direction) {
|
||||
case Right:
|
||||
data[0] = avail.left();
|
||||
data[1] = 0;
|
||||
break;
|
||||
case Down:
|
||||
data[0] = avail.top();
|
||||
data[1] = 1;
|
||||
case Up:
|
||||
location = BottomEdge;
|
||||
break;
|
||||
case Left:
|
||||
data[0] = avail.right();
|
||||
data[1] = 2;
|
||||
location = RightEdge;
|
||||
break;
|
||||
case Right:
|
||||
location = LeftEdge;
|
||||
break;
|
||||
case Down:
|
||||
location = TopEdge;
|
||||
break;
|
||||
case Up:
|
||||
default:
|
||||
data[0] = avail.bottom();
|
||||
data[1] = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
XChangeProperty(dpy, winId(), atom, atom, 32, PropModeReplace,
|
||||
reinterpret_cast<unsigned char *>(data.data()), data.size());
|
||||
#endif
|
||||
Plasma::WindowEffects::setSlidingWindow(winId(), location);
|
||||
|
||||
show();
|
||||
|
||||
|
1
dialog.h
1
dialog.h
@ -120,6 +120,7 @@ class PLASMA_EXPORT Dialog : public QWidget
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
void hideEvent(QHideEvent *event);
|
||||
void showEvent(QShowEvent *event);
|
||||
void focusInEvent(QFocusEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
|
83
windoweffects.cpp
Normal file
83
windoweffects.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
namespace WindowEffects
|
||||
{
|
||||
|
||||
void setSlidingWindow(WId id, Plasma::Location location)
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
Display *dpy = QX11Info::display();
|
||||
//set again the atom, the location could have changed
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
|
||||
Window dummy;
|
||||
int x;
|
||||
int y;
|
||||
uint width;
|
||||
uint height;
|
||||
uint bw;
|
||||
uint d;
|
||||
XGetGeometry(dpy, id, &dummy, &x, &y, &width, &height, &bw, &d);
|
||||
|
||||
QRect avail = desktop->availableGeometry(QPoint(x, y));//desktop->screenNumber(pos()));
|
||||
|
||||
Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False );
|
||||
QVarLengthArray<long, 1024> data(2);
|
||||
|
||||
switch (location) {
|
||||
case LeftEdge:
|
||||
data[0] = avail.left();
|
||||
data[1] = 0;
|
||||
break;
|
||||
case TopEdge:
|
||||
data[0] = avail.top();
|
||||
data[1] = 1;
|
||||
break;
|
||||
case RightEdge:
|
||||
data[0] = avail.right();
|
||||
data[1] = 2;
|
||||
break;
|
||||
case BottomEdge:
|
||||
data[0] = avail.bottom();
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
50
windoweffects.h
Normal file
50
windoweffects.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_WINDOWEFFECTS_H
|
||||
#define PLASMA_WINDOWEFFECTS_H
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QDesktopWidget>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
#include <plasma/plasma.h>
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <X11/Xlib.h>
|
||||
#include <QX11Info>
|
||||
#endif
|
||||
|
||||
/** @headerfile plasma/windoweffect.h <Plasma/PaintUtils> */
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
/**
|
||||
* Namespace for all window effects for Plasma/KWin interaction
|
||||
*/
|
||||
namespace WindowEffects
|
||||
{
|
||||
PLASMA_EXPORT void setSlidingWindow(WId id, Plasma::Location location);
|
||||
}
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user