MCPcopy
hub / github.com/pickle-com/glass / moveToDisplay

Method moveToDisplay

src/window/smoothMovementManager.js:38–61  ·  view source on GitHub ↗
(displayId)

Source from the content-addressed store, hash-verified

36 }
37
38 moveToDisplay(displayId) {
39 const header = this.windowPool.get('header');
40 if (!this._isWindowValid(header) || !header.isVisible() || this.isAnimating) return;
41
42 const targetDisplay = this.getDisplayById(displayId);
43 if (!targetDisplay) return;
44
45 const currentBounds = header.getBounds();
46 const currentDisplay = this.getCurrentDisplay(header);
47
48 if (currentDisplay.id === targetDisplay.id) return;
49
50 const relativeX = (currentBounds.x - currentDisplay.workArea.x) / currentDisplay.workAreaSize.width;
51 const relativeY = (currentBounds.y - currentDisplay.workArea.y) / currentDisplay.workAreaSize.height;
52 const targetX = targetDisplay.workArea.x + targetDisplay.workAreaSize.width * relativeX;
53 const targetY = targetDisplay.workArea.y + targetDisplay.workAreaSize.height * relativeY;
54
55 const finalX = Math.max(targetDisplay.workArea.x, Math.min(targetDisplay.workArea.x + targetDisplay.workAreaSize.width - currentBounds.width, targetX));
56 const finalY = Math.max(targetDisplay.workArea.y, Math.min(targetDisplay.workArea.y + targetDisplay.workAreaSize.height - currentBounds.height, targetY));
57
58 this.headerPosition = { x: currentBounds.x, y: currentBounds.y };
59 this.animateToPosition(header, finalX, finalY);
60 this.currentDisplayId = targetDisplay.id;
61 }
62
63 hideToEdge(edge, callback, { instant = false } = {}) {
64 const header = this.windowPool.get('header');

Callers 2

setupIpcHandlersFunction · 0.80
registerShortcutsMethod · 0.80

Calls 3

_isWindowValidMethod · 0.95
animateToPositionMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected