/usr/share/cinnamon/js/ui/windowEffects.js is in cinnamon-common 2.8.6-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | const Clutter = imports.gi.Clutter;
const Meta = imports.gi.Meta;
const AppletManager = imports.ui.appletManager;
const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
function Effect(){
throw new TypeError("Trying to instantiate abstract class WindowEffects.Effect");
}
Effect.prototype = {
_init: function(wm){
//wm is the instance of windowManger.js
this.wm = wm;
},
_end: function(actor){
actor.set_scale(1, 1);
actor.opacity = actor.orig_opacity || 255;
actor.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_WEST);
},
_fadeWindow: function(cinnamonwm, actor, opacity, time, transition){
Tweener.addTween(actor, {
opacity: opacity,
time: time,
min: 0,
max: 255,
transition: transition,
onComplete: this.wm._endWindowEffect,
onCompleteScope: this.wm,
onCompleteParams: [cinnamonwm, this.name, actor]
});
},
_scaleWindow: function(cinnamonwm, actor, scale_x, scale_y, time, transition, keepAnchorPoint){
if (!keepAnchorPoint)
actor.move_anchor_point_from_gravity(Clutter.Gravity.CENTER);
Tweener.addTween(actor, {
scale_x: scale_x,
scale_y: scale_y,
time: time,
min: 0,
transition: transition,
onComplete: this.wm._endWindowEffect,
onCompleteScope: this.wm,
onCompleteParams: [cinnamonwm, this.name, actor]
});
},
_moveWindow: function(cinnamonwm, actor, x, y, time, transition){
Tweener.addTween(actor, {
x: x,
y: y,
time: time,
transition: transition,
onComplete: this.wm._endWindowEffect,
onCompleteScope: this.wm,
onCompleteParams: [cinnamonwm, this.name, actor]
});
}
};
function Map(){
this._init.apply(this, arguments);
}
Map.prototype = {
__proto__: Effect.prototype,
name: "map",
arrayName: "_mapping",
wmCompleteName: "completed_map",
scale: function(cinnamonwm, actor, time, transition){
actor.set_scale(0, 0);
this._scaleWindow(cinnamonwm, actor, 1, 1, time, transition);
},
fade: function(cinnamonwm, actor, time, transition){
actor.opacity = 0;
this._fadeWindow(cinnamonwm, actor, actor.orig_opacity, time, transition);
},
blend: function(cinnamonwm, actor, time, transition){
actor.opacity = 0;
actor.set_scale(1.5, 1.5);
this._fadeWindow(cinnamonwm, actor, actor.orig_opacity, time, transition);
this._scaleWindow(cinnamonwm, actor, 1, 1, time, transition);
},
move: function(cinnamonwm, actor, time, transition){
let [width, height] = actor.get_allocation_box().get_size();
let [xDest, yDest] = actor.get_transformed_position();
xDest += width /= 2;
yDest += height /= 2;
let [xSrc, ySrc] = global.get_pointer();
xSrc -= width;
ySrc -= height;
actor.set_position(xSrc, ySrc);
actor.set_scale(0, 0);
this._scaleWindow(cinnamonwm, actor, 1, 1, time, transition);
this._moveWindow(cinnamonwm, actor, xDest, yDest, time, transition);
},
flyUp: function(cinnamonwm, actor, time, transition){
//FIXME: somehow we need this line to get the correct position, without it will return [0, 0]
actor.get_allocation_box().get_size();
let [xDest, yDest] = actor.get_transformed_position();
let ySrc = global.stage.get_height();
actor.set_position(xDest, ySrc);
let dist = Math.abs(ySrc - yDest);
time *= dist / Main.layoutManager.primaryMonitor.height * 2; // The transition time set is the time if the animation starts/ends at the middle of the screen. Scale it proportional to the actual distance so that the speed of all animations will be constant.
this._moveWindow(cinnamonwm, actor, xDest, yDest, time, transition);
},
flyDown: function(cinnamonwm, actor, time, transition){
//FIXME - see also flyUp
actor.get_allocation_box().get_size();
let [xDest, yDest] = actor.get_transformed_position();
let ySrc = -actor.get_allocation_box().get_height();
actor.set_position(xDest, ySrc);
let dist = Math.abs(ySrc - yDest);
time *= dist / Main.layoutManager.primaryMonitor.height * 2; // The time time set is the time if the animation starts/ends at the middle of the screen. Scale it proportional to the actual distance so that the speed of all animations will be constant.
this._moveWindow(cinnamonwm, actor, xDest, yDest, time, transition);
},
traditional: function(cinnamonwm, actor, time, transition) {
switch (actor._windowType) {
case Meta.WindowType.NORMAL:
actor.set_pivot_point(0, 0);
actor.scale_x = 0.01;
actor.scale_y = 0.05;
actor.opacity = 0;
this._fadeWindow(cinnamonwm, actor, actor.orig_opacity, time, transition);
this._scaleWindow(cinnamonwm, actor, 1, 1, time, transition);
break;
case Meta.WindowType.MODAL_DIALOG:
case Meta.WindowType.DIALOG:
actor.set_pivot_point(0, 0);
actor.scale_x = 1;
actor.scale_y = 0;
actor.opacity = 0;
this._fadeWindow(cinnamonwm, actor, actor.orig_opacity, time, transition);
this._scaleWindow(cinnamonwm, actor, 1, 1, time, transition);
break;
default:
this._fadeWindow(cinnamonwm, actor, actor.orig_opacity, time, transition);
}
}
}
function Close(){
this._init.apply(this, arguments);
}
Close.prototype = {
__proto__: Effect.prototype,
name: "close",
arrayName: "_destroying",
wmCompleteName: "completed_destroy",
_end: function(actor){
let parent = actor.get_meta_window().get_transient_for();
if(parent && actor._parentDestroyId){
parent.disconnect(actor._parentDestroyId);
actor._parentDestroyId = 0;
}
},
scale: function(cinnamonwm, actor, time, transition){
this._scaleWindow(cinnamonwm, actor, 0, 0, time, transition);
},
fade: function(cinnamonwm, actor, time, transition){
Tweener.removeTweens(actor);
this._fadeWindow(cinnamonwm, actor, 0, time, transition);
},
blend: function(cinnamonwm, actor, time, transition){
this._fadeWindow(cinnamonwm, actor, 0, time, transition);
this._scaleWindow(cinnamonwm, actor, 1.5, 1.5, time, transition);
},
move: function(cinnamonwm, actor, time, transition){
let [xDest, yDest] = global.get_pointer();
this._scaleWindow(cinnamonwm, actor, 0, 0, time, transition);
this._moveWindow(cinnamonwm, actor, xDest, yDest, time, transition);
},
flyUp: function(cinnamonwm, actor, time, transition){
let xDest = actor.get_transformed_position()[0];
let yDest = -actor.get_allocation_box().get_height();
let dist = Math.abs(actor.get_transformed_position()[1] - yDest);
time *= dist / Main.layoutManager.primaryMonitor.height * 2; // The time time set is the time if the animation starts/ends at the middle of the screen. Scale it proportional to the actual distance so that the speed of all animations will be constant.
this._moveWindow(cinnamonwm, actor, xDest, yDest, time, transition);
},
flyDown: function(cinnamonwm, actor, time, transition){
let xDest = actor.get_transformed_position()[0];
let yDest = global.stage.get_height();
let dist = Math.abs(actor.get_transformed_position()[1] - yDest);
time *= dist / Main.layoutManager.primaryMonitor.height * 2; // The transition time set is the time if the animation starts/ends at the middle of the screen. Scale it proportional to the actual distance so that the speed of all animations will be constant.
this._moveWindow(cinnamonwm, actor, xDest, yDest, time, transition);
},
traditional: function(cinnamonwm, actor, time, transition) {
switch (actor._windowType) {
case Meta.WindowType.NORMAL:
actor.set_pivot_point(0, 0);
this._scaleWindow(cinnamonwm, actor, 0.8, 0.8, time, transition);
this._fadeWindow(cinnamonwm, actor, 0, time, transition);
break;
case Meta.WindowType.MODAL_DIALOG:
case Meta.WindowType.DIALOG:
actor.set_pivot_point(0, 0);
this._fadeWindow(cinnamonwm, actor, 0.5, time, transition);
this._scaleWindow(cinnamonwm, actor, 1.0, 0, time, transition);
break;
default:
this.scale(cinnamonwm, actor, time, transition);
}
}
}
function Minimize(){
this._init.apply(this, arguments);
}
Minimize.prototype = {
__proto__: Close.prototype,
name: "minimize",
arrayName: "_minimizing",
wmCompleteName: "completed_minimize",
//use default _end method
_end: Effect.prototype._end,
traditional: function(cinnamonwm, actor, time, transition) {
let success;
let geom = new Meta.Rectangle();
success = actor.meta_window.get_icon_geometry(geom);
if (success) {
actor.set_scale(1, 1);
let xDest, yDest, xScale, yScale;
xDest = geom.x;
yDest = geom.y;
xScale = geom.width / actor.width;
yScale = geom.height / actor.height;
actor.get_meta_window()._cinnamonwm_has_origin = true;
this._moveWindow(cinnamonwm, actor, xDest, yDest, time, transition);
this._scaleWindow(cinnamonwm, actor, xScale, yScale, time, transition, true);
this._fadeWindow(cinnamonwm, actor, 0, time, transition);
} else {
this.scale(cinnamonwm, actor, time, transition); // fall-back effect
}
}
}
function Unminimize(){
this._init.apply(this, arguments);
}
Unminimize.prototype = {
//unminimizing is a "map" effect but should use "minimize" setting values
__proto__: Effect.prototype,
name: "unminimize",
arrayName: "_mapping",
wmCompleteName: "completed_map",
_end: Map.prototype._end,
traditional: function(cinnamonwm, actor, time, transition) {
let success;
let geom = new Meta.Rectangle();
success = actor.meta_window.get_icon_geometry(geom);
if (success) {
actor.set_scale(0.1, 0.1);
actor.opacity = 0;
let xSrc = geom.x;
let ySrc = geom.y;
let [xDest, yDest] = actor.get_transformed_position();
actor.set_position(xSrc, ySrc);
this._moveWindow(cinnamonwm, actor, xDest, yDest, time, transition);
this._scaleWindow(cinnamonwm, actor, 1, 1, time, transition, true);
this._fadeWindow(cinnamonwm, actor, actor.orig_opacity, time, transition);
} else {
throw "No origin found";
}
}
}
function Tile(){
this._init.apply(this, arguments);
}
Tile.prototype = {
__proto__: Effect.prototype,
name: "tile",
arrayName: "_tiling",
wmCompleteName: "completed_tile",
scale: function(cinnamonwm, actor, time, transition, args){
let [targetX, targetY, targetWidth, targetHeight] = args;
if(targetWidth == actor.width)
targetWidth -= 1;
if(targetHeight == actor.height)
targetHeight -= 1;
let scale_x = targetWidth / actor.width;
let scale_y = targetHeight / actor.height;
let anchor_x = (actor.x - targetX) * actor.width / (targetWidth - actor.width);
let anchor_y = (actor.y - targetY) * actor.height / (targetHeight - actor.height);
actor.move_anchor_point(anchor_x, anchor_y);
this._scaleWindow(cinnamonwm, actor, scale_x, scale_y, time, transition, true);
}
}
function Maximize(){
this._init.apply(this, arguments);
}
Maximize.prototype = {
__proto__: Tile.prototype,
name: "maximize",
arrayName: "_maximizing",
wmCompleteName: "completed_maximize",
}
function Unmaximize(){
this._init.apply(this, arguments);
}
Unmaximize.prototype = {
__proto__: Tile.prototype,
name: "unmaximize",
arrayName: "_unmaximizing",
wmCompleteName: "completed_unmaximize"
}
|