Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. /********************************************************************
  2. This file is part of the KDE project.
  3.  
  4. Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *********************************************************************/
  19.  
  20. "use strict";
  21.  
  22. function sleep(miliseconds) {
  23. var currentTime = new Date().getTime();
  24.  
  25. while (currentTime + miliseconds >= new Date().getTime()) {
  26. }
  27. }
  28.  
  29. var maximizeEffect = {
  30. duration: animationTime(250),
  31. loadConfig: function () {
  32. maximizeEffect.duration = animationTime(250);
  33. },
  34. maximizeChanged: function (window) {
  35. var m = Math.floor((Math.random() * 2) + 1);
  36. sleep(16); //Skip a frame at 60hz to skip a glitch.
  37. if (!window.oldGeometry) {
  38. return;
  39. }
  40. window.setData(Effect.WindowForceBlurRole, true);
  41. var oldGeometry, newGeometry;
  42. oldGeometry = window.oldGeometry;
  43. newGeometry = window.geometry;
  44. if (oldGeometry.width == newGeometry.width && oldGeometry.height == newGeometry.height)
  45. oldGeometry = window.olderGeometry;
  46. window.olderGeometry = window.oldGeometry;
  47. window.oldGeometry = newGeometry;
  48. window.maximizeAnimation1 = animate({
  49. window: window,
  50. duration: maximizeEffect.duration,
  51. animations: [{
  52. type: Effect.Size,
  53. to: {
  54. value1: newGeometry.width,
  55. value2: newGeometry.height
  56. },
  57. from: {
  58. value1: oldGeometry.width,
  59. value2: oldGeometry.height
  60. }
  61. }, {
  62. type: Effect.Translation,
  63. to: {
  64. value1: 0,
  65. value2: 0
  66. },
  67. from: {
  68. value1: oldGeometry.x - newGeometry.x - (newGeometry.width / 2 - oldGeometry.width / 2),
  69. value2: oldGeometry.y - newGeometry.y - (newGeometry.height / 2 - oldGeometry.height / 2)
  70. }
  71. }]
  72. });
  73. //if (!window.resize) {
  74. if (1 == 2 ) { // disabled the routine because
  75. // CrossFadePrevious+xrender grabs a garbled texture as the start crossfade point
  76. sleep(16);
  77. window.maximizeAnimation2 =animate({
  78. window: window,
  79. duration: maximizeEffect.duration,
  80. animations: [{
  81. delay: animationTime(32),
  82. type: Effect.CrossFadePrevious,
  83. to: 1.0,
  84. from: 0.0
  85. }]
  86. });
  87. }
  88. },
  89. restoreForceBlurState: function(window) {
  90. window.setData(Effect.WindowForceBlurRole, null);
  91. },
  92. geometryChange: function (window, oldGeometry) {
  93. //sleep(100); inutile
  94. if (window.maximizeAnimation1) {
  95. if (window.geometry.width != window.oldGeometry.width ||
  96. window.geometry.height != window.oldGeometry.height) {
  97. cancel(window.maximizeAnimation1);
  98. delete window.maximizeAnimation1;
  99. if (window.maximizeAnimation2) {
  100. cancel(window.maximizeAnimation2);
  101. delete window.maximizeAnimation2;
  102. }
  103. }
  104. }
  105. window.oldGeometry = window.geometry;
  106. window.olderGeometry = oldGeometry;
  107. },
  108. init: function () {
  109. effect.configChanged.connect(maximizeEffect.loadConfig);
  110. effects.windowGeometryShapeChanged.connect(maximizeEffect.geometryChange);
  111. effects.windowMaximizedStateChanged.connect(maximizeEffect.maximizeChanged);
  112. effect.animationEnded.connect(maximizeEffect.restoreForceBlurState);
  113. }
  114. };
  115. maximizeEffect.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement