On Sunday 26 July 2009, Marco Martin wrote: > On Saturday 25 July 2009, Aaron J. Seigo wrote: > > On Friday 24 July 2009, Marco Martin wrote: > > > what about a small library (just statics probably) in workspace to deal > > > with this stuff? KWindowSystemExtra? > > > > the code needs to be accessible from libplasma though so that e.g. > > PopupApplet can animate its stuff. > > > > that's why i suggested Animator. a Plasma::WindowEffects namespace would > > be fine as well imo. > > i'm really on the fence on where to put this and how to call it. > Becasue if we put other stuff like that like the taskbar thumbnails and the > glow effect they wouldn't have much to do with animation, and i'm kinda > wondering if plasma is the right namespace/lib for that, hmm.. > anyways next patch is a tiny WindowEffect namespace (or maybe WindowUtils? > so it mnatches with PaintUtils) here it is
Cheers, Marco Martin
Index: dialog.h =================================================================== --- dialog.h (revision 1002551) +++ dialog.h (working copy) @@ -120,6 +120,7 @@ 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); Index: windoweffects.cpp =================================================================== --- windoweffects.cpp (revision 0) +++ windoweffects.cpp (revision 0) @@ -0,0 +1,83 @@ +/* + * Copyright 2009 Marco Martin <notm...@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 +} + +} + +} Index: dialog.cpp =================================================================== --- dialog.cpp (revision 1002551) +++ dialog.cpp (working copy) @@ -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 @@ 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 @@ 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())); + Location location = Desktop; - Display *dpy = QX11Info::display(); - Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False ); - QVarLengthArray<long, 1024> data(2); - switch (direction) { + case Down: + location = BottomEdge; + break; + case Right: + location = RightEdge; + break; case Left: - data[0] = avail.left(); - data[1] = 0; + location = LeftEdge; break; case Up: - data[0] = avail.top(); - data[1] = 1; + location = TopEdge; break; - case Right: - data[0] = avail.right(); - data[1] = 2; - 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 @@ return; } -#ifdef Q_WS_X11 - QDesktopWidget *desktop = QApplication::desktop(); - QRect avail = desktop->availableGeometry(desktop->screenNumber(pos())); + //copied to not add new api + Location location = Desktop; - Display *dpy = QX11Info::display(); - Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False ); - QVarLengthArray<long, 1024> data(2); - switch (direction) { + case Up: + location = BottomEdge; + break; + case Left: + location = RightEdge; + break; case Right: - data[0] = avail.left(); - data[1] = 0; + location = LeftEdge; break; case Down: - data[0] = avail.top(); - data[1] = 1; + location = TopEdge; break; - case Left: - data[0] = avail.right(); - data[1] = 2; - 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(); Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 1002551) +++ CMakeLists.txt (working copy) @@ -103,6 +103,7 @@ version.cpp view.cpp wallpaper.cpp + windoweffects.cpp widgets/checkbox.cpp widgets/combobox.cpp widgets/flashinglabel.cpp @@ -211,6 +212,7 @@ extendergroup.h extenderitem.h paintutils.h + windoweffects.h framesvg.h plasma.h plasma_export.h Index: windoweffects.h =================================================================== --- windoweffects.h (revision 0) +++ windoweffects.h (revision 0) @@ -0,0 +1,50 @@ +/* + * Copyright 2009 Marco Martin <notm...@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 +
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel