[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: panels and popups sliding effect
From:       Marco Martin <notmart () gmail ! com>
Date:       2009-07-24 14:44:36
Message-ID: 57b05eda0907240744i41dd89c3gbff646be0e389257 () mail ! gmail ! com
[Download RAW message or body]

On 7/24/09, Marco Martin <notmart@gmail.com> wrote:
> On Friday 24 July 2009, Aaron J. Seigo wrote:
>> On Thursday 23 July 2009, Marco Martin wrote:
>> > animateWindow(winId, Animation, Location);
>>
>> the same for the highlight windows and other xatom based affects as well.
>> animateWindow is a bit generic of a name given that, but i think it's
>> completely the right idea/direction.
> not sure animator is the right place for other effects like highlight
> windows,
> taskbar thumbnails and things like that
> what about a small library (just statics probably) in workspace to deal with
> this stuff? KWindowSystemExtra?
>
> iirc in the plasma-kwin meeting at akademy Lubos mentioned to put them
> directly in KWindowsystem? but perhaps is too kde-specific stuff?

added a setSlidingWindow (not animatewindow or something like this
because it doesn't actually animates, it just tells the window it
-can- animate) function to animator, the thing becomes a lot cleaner,
but anyways i think that a different (even non plasma) library would
be better

Cheers,
Marco Martin

>
> Cheers,
> Marco Martin
>

["windoweffectanimartor.diff" (application/octet-stream)]

Index: animator.cpp
===================================================================
--- animator.cpp	(revision 1000396)
+++ animator.cpp	(working copy)
@@ -23,6 +23,9 @@
 #include <QGraphicsItem>
 #include <QTimeLine>
 #include <QTimerEvent>
+#include <QDesktopWidget>
+#include <QApplication>
+#include <QVarLengthArray>
 
 #include <kconfig.h>
 #include <kconfiggroup.h>
@@ -32,6 +35,11 @@
 
 #include "animationdriver.h"
 
+#ifdef Q_WS_X11
+#include <X11/Xlib.h>
+#include <QX11Info>
+#endif
+
 namespace Plasma
 {
 
@@ -605,6 +613,56 @@
             !d->customAnims.isEmpty());
 }
 
+void Animator::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
+}
+
 void Animator::timerEvent(QTimerEvent *event)
 {
     if (event->timerId() != d->timerId) {
Index: dialog.cpp
===================================================================
--- dialog.cpp	(revision 1001605)
+++ dialog.cpp	(working copy)
@@ -559,37 +559,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::Animator::self()->setSlidingWindow(winId(), location);
 
     hide();
 }
@@ -601,36 +590,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::Animator::self()->setSlidingWindow(winId(), location);
 
     show();
 
Index: animator.h
===================================================================
--- animator.h	(revision 1000396)
+++ animator.h	(working copy)
@@ -25,6 +25,7 @@
 #include <QtCore/QObject>
 
 #include <plasma/plasma_export.h>
+#include <plasma/plasma.h>
 
 class QGraphicsItem;
 class QTimeLine;
@@ -152,6 +153,8 @@
      */
     Q_INVOKABLE bool isAnimating() const;
 
+    void setSlidingWindow(WId id, Plasma::Location location);
+
 Q_SIGNALS:
     void animationFinished(QGraphicsItem *item, Plasma::Animator::Animation anim);
     void movementFinished(QGraphicsItem *item);


_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic