* Shows the window preview in from the side it was triggered on.
()
| 355 | * Shows the window preview in from the side it was triggered on. |
| 356 | */ |
| 357 | showPreview() { |
| 358 | // only show if have valid scale |
| 359 | const scale = Settings.prefs.edge_preview_scale; |
| 360 | if (scale <= 0) { |
| 361 | return; |
| 362 | } |
| 363 | |
| 364 | // don't show if window grabbed |
| 365 | if (Grab.grabbed) { |
| 366 | return; |
| 367 | } |
| 368 | |
| 369 | /** |
| 370 | * if timeout is enabled, only show if valid timeout (e.g. if SHOW_DELAY <= timeout, |
| 371 | * then won't see the preview anyway). |
| 372 | */ |
| 373 | if (Settings.prefs.edge_preview_timeout_enable && |
| 374 | Settings.prefs.edge_preview_timeout <= this.SHOW_DELAY |
| 375 | ) { |
| 376 | return; |
| 377 | } |
| 378 | |
| 379 | let [x, y] = global.get_pointer(); |
| 380 | const actor = this.target.get_compositor_private(); |
| 381 | const clone = new Clutter.Clone({ source: actor }); |
| 382 | this.clone = clone; |
| 383 | |
| 384 | // Remove any window clips, and show the metaWindow.clone's |
| 385 | actor.remove_clip(); |
| 386 | Tiling.animateWindow(this.target); |
| 387 | |
| 388 | // set clone parameters |
| 389 | clone.opacity = 255 * 0.95; |
| 390 | |
| 391 | clone.set_scale(scale, scale); |
| 392 | Main.uiGroup.add_child(clone); |
| 393 | |
| 394 | const monitor = this.monitor; |
| 395 | const scaleWidth = scale * clone.width; |
| 396 | const scaleHeight = scale * clone.height; |
| 397 | if (this._direction === Meta.MotionDirection.RIGHT) { |
| 398 | x = monitor.x + monitor.width - scaleWidth; |
| 399 | } |
| 400 | else { |
| 401 | x = monitor.x; |
| 402 | } |
| 403 | |
| 404 | // calculate y position - center of mouse |
| 405 | y -= (scale * clone.height) / 2; |
| 406 | |
| 407 | // bound to remain within view |
| 408 | const workArea = this.getWorkArea(); |
| 409 | y = Math.max(y, workArea.y); |
| 410 | y = Math.min(y, workArea.y + workArea.height - scaleHeight); |
| 411 | |
| 412 | clone.set_position(x, y); |
| 413 | } |
| 414 |
no test coverage detected