MCPcopy Index your code
hub / github.com/paperwm/PaperWM / setTarget

Method setTarget

stackoverlay.js:415–481  ·  view source on GitHub ↗
(space, index)

Source from the content-addressed store, hash-verified

413 }
414
415 setTarget(space, index) {
416 this.removePreview();
417
418 let bail = () => {
419 this.target = null;
420 this.overlay.width = 0;
421 return false;
422 };
423
424 if (space === null || Tiling.inPreview) {
425 // No target. Eg. if we're at the left- or right-most window
426 return bail();
427 }
428
429 let mru = global.display.get_tab_list(Meta.TabList.NORMAL_ALL,
430 space.workspace);
431 let column = space[index];
432 this.target = mru.filter(w => column.includes(w))[0];
433 let metaWindow = this.target;
434 if (!metaWindow)
435 return;
436
437 let overlay = this.overlay;
438 overlay.y = this.monitor.y + Main.layoutManager.panelBox.height + Settings.prefs.vertical_margin;
439
440 // Assume the resize edge is at least this big (empirically found..)
441 const minResizeEdge = 8;
442
443 if (this._direction === Meta.MotionDirection.LEFT) {
444 let column = space[space.indexOf(metaWindow) + 1];
445 let neighbour = column &&
446 global.display.sort_windows_by_stacking(column).reverse()[0];
447
448 if (!neighbour)
449 return bail(); // Should normally have a neighbour. Bail!
450
451 let width = neighbour.clone.targetX + space.targetX - minResizeEdge;
452 if (space.isPlaceable(metaWindow) || Utils.is_wayland_compositor())
453 width = Math.min(width, 1);
454 overlay.x = this.monitor.x;
455 overlay.width = Math.max(width, 1);
456 Utils.actor_raise(overlay, neighbour.get_compositor_private());
457 } else {
458 let column = space[space.indexOf(metaWindow) - 1];
459 let neighbour = column &&
460 global.display.sort_windows_by_stacking(column).reverse()[0];
461 if (!neighbour)
462 return bail(); // Should normally have a neighbour. Bail!
463
464 let frame = neighbour.get_frame_rect();
465 frame.x = neighbour.clone.targetX + space.targetX;
466 let width = this.monitor.width - (frame.x + frame.width) - minResizeEdge;
467 if (space.isPlaceable(metaWindow) || Utils.is_wayland_compositor())
468 width = 1;
469 width = Math.max(width, 1);
470 overlay.x = this.monitor.x + this.monitor.width - width;
471 overlay.width = width;
472 Utils.actor_raise(overlay, neighbour.get_compositor_private());

Callers 3

constructorMethod · 0.95
fixOverlaysMethod · 0.80
resetMethod · 0.80

Calls 5

removePreviewMethod · 0.95
indexOfMethod · 0.80
isPlaceableMethod · 0.80
hideMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected