Advertisement
Guest User

KWin Cool Effect 0.2

a guest
Sep 8th, 2013
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * global effect, effects, animate, animationTime, Effect, QEasingCurve
  3.  */
  4. var CoolEffect = {
  5.     debug: function (message) {
  6.         // TODO
  7.         print(message); // WTF?
  8.     },
  9.  
  10.     duration: animationTime(250),
  11.     isfadeWindow: function(window) {
  12.         if (window.deleted && effect.isGrabbed(window, Effect.WindowClosedGrabRole)) {
  13.             return false;
  14.         } else if (!window.deleted && effect.isGrabbed(window, Effect.WindowAddedGrabRole)) {
  15.             return false;
  16.         }
  17.  
  18.         var isFade = window.onCurrentDesktop && !CoolEffect.isLoginWindow(window) && ! window.desktopWindow &&
  19.             !window.utility && !window.minimized;
  20.  
  21.         // Filter out menus and others
  22.         isFade = isFade && (window.normalWindow || window.dialog) && window.hasDecoration;
  23.  
  24.         return isFade;
  25.     },
  26.     isLoginWindow: function(window) {
  27.         return window.windowClass == "ksplashx ksplashx" ||
  28.             window.windowClass == "ksplashsimple ksplashsimple" ||
  29.             window.windowClass == "qt-subapplication ksplashqml";
  30.     },
  31.     fadeWindow: function (window, direction) {
  32.         animate({
  33.             window: window,
  34.             duration: CoolEffect.duration,
  35.             animations: [{
  36.                 type: Effect.Opacity,
  37.                 curve: QEasingCurve.InOutQuad,
  38.                 from: direction === 'in' ? 0.0 : 1.0,
  39.                 to: direction === 'in' ? 1.0 : 0.0
  40.             }, {
  41.                 type: Effect.Scale,
  42.                 curve: QEasingCurve.InOutQuad,
  43.                 from: direction === 'in' ? 0.75 : 1.0,
  44.                 to: direction === 'in' ? 1.0 : 0.75
  45.             }]
  46.         });
  47.     },
  48.     shown: function(window) {
  49.         if (CoolEffect.isfadeWindow(window))
  50.             CoolEffect.fadeWindow(window, 'in');
  51.     },
  52.     closed: function (window) {
  53.         if (CoolEffect.isfadeWindow(window))
  54.             CoolEffect.fadeWindow(window, 'out');
  55.     },
  56.     init: function () {
  57.         effects.windowAdded.connect(CoolEffect.shown);
  58.         effects.windowClosed.connect(CoolEffect.closed);
  59.     }
  60. };
  61.  
  62. CoolEffect.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement