MCPcopy
hub / github.com/paperwm/PaperWM / takeWindow

Function takeWindow

tiling.js:5407–5556  ·  view source on GitHub ↗
(metaWindow, space, options = {})

Source from the content-addressed store, hash-verified

5405 navigating. When done, insert all the detached windows again.
5406 */
5407export function takeWindow(metaWindow, space, options = {}) {
5408 space = space ?? spaces.selectedSpace;
5409 metaWindow = metaWindow ?? space.selectedWindow;
5410 const navigator = options?.navigator ?? Navigator.getNavigator();
5411 const existing = options?.existing ?? false;
5412
5413 if (!existing && !space.removeWindow(metaWindow))
5414 return;
5415
5416 // setup animate function
5417 const animateTake = (window, existing) => {
5418 navigator._moving.push(window);
5419 if (!existing) {
5420 Utils.actor_add_child(backgroundGroup, metaWindow.clone);
5421 }
5422
5423 const lowest = navigator._moving[navigator._moving.length - 2];
5424 lowest && backgroundGroup.set_child_below_sibling(
5425 window.clone,
5426 lowest.clone);
5427 const point = space.cloneContainer.apply_relative_transform_to_point(
5428 backgroundGroup, new Graphene.Point3D({
5429 x: window.clone.x,
5430 y: window.clone.y,
5431 }));
5432
5433 if (!existing) {
5434 window.clone.set_position(point.x, point.y);
5435 }
5436
5437 let x = Math.round(space.monitor.x + space.monitor.width -
5438 (0.08 * space.monitor.width * (1 + navigator._moving.length)));
5439 let y = Math.round(space.monitor.y + space.monitor.height * 2 / 3) +
5440 16 * navigator._moving.length;
5441 animateWindow(window);
5442 Easer.addEase(window.clone,
5443 {
5444 x, y,
5445 time: Settings.prefs.animation_time,
5446 });
5447 };
5448
5449 if (!navigator._moving) {
5450 navigator.showTakeHint(true);
5451 navigator._moving = [];
5452
5453 const selectedSpace = () => spaces.selectedSpace;
5454 const changeSpace = metaWindow => {
5455 const space = selectedSpace();
5456 if (spaces.spaceOfWindow(metaWindow) !== space) {
5457 metaWindow.change_workspace(space.workspace);
5458 }
5459 };
5460
5461 /**
5462 * Cycling function which orders the navigator._moving
5463 * array according to direction.
5464 */

Callers 2

selectSequenceSpaceMethod · 0.85
selectStackSpaceMethod · 0.85

Calls 11

changeSpaceFunction · 0.85
insertWindowFunction · 0.85
selectedSpaceFunction · 0.85
ensureViewportFunction · 0.85
cyclerFunction · 0.85
animateTakeFunction · 0.85
showTakeHintMethod · 0.80
addKeypressCallbackMethod · 0.80
connectOneShotMethod · 0.80
removeWindowMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected