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

Function focus_handler

tiling.js:4597–4715  ·  view source on GitHub ↗
(metaWindow)

Source from the content-addressed store, hash-verified

4595
4596// `MetaWindow::focus` handling
4597export function focus_handler(metaWindow) {
4598 console.debug("focus:", metaWindow?.title);
4599 if (Scratch.isScratchWindow(metaWindow)) {
4600 setAllWorkspacesInactive();
4601 Scratch.makeScratch(metaWindow);
4602 Topbar.fixTopBar();
4603 return;
4604 }
4605
4606 // If metaWindow is a transient window, return (after deselecting tiled focus indicators)
4607 if (isTransient(metaWindow)) {
4608 setAllWorkspacesInactive();
4609 return;
4610 }
4611
4612 let space = spaces.spaceOfWindow(metaWindow);
4613
4614 // if window is on another monitor then warp pointer there
4615 if (!Main.overview.visible &&
4616 Utils.monitorAtCurrentPoint() !== space.monitor) {
4617 Utils.warpPointerToMonitor(space.monitor);
4618 }
4619
4620 if (metaWindow.fullscreen) {
4621 space.enableWindowPositionBar(false);
4622 space.setSpaceTopbarElementsVisible(false);
4623 space.hideSelection();
4624 if (!metaWindow.is_above()) {
4625 metaWindow.make_above();
4626 }
4627 }
4628 else {
4629 space.getWindows().filter(w => w.fullscreen).forEach(w => {
4630 if (
4631 w._fullscreen_above !== null &&
4632 !w._fullscreen_above
4633 ) {
4634 w.unmake_above();
4635 }
4636 });
4637
4638 let needLayout = false;
4639 /**
4640 * If has fullscreen window - when selected non-fullscreen window, do layout:
4641 * For non-topbar spaces, Bring down fullscreen windows to mimic gnome behaviour with a topbar,
4642 * Also ensures if columns group, then it's windows are correctly proportioned.
4643 */
4644 if (space.hasFullScreenWindow()) {
4645 needLayout = true;
4646 }
4647
4648 /**
4649 * if there then clone.y shouldn't be 0. This can happen though if a window
4650 * is fullscreened when `layout` is called. In this case, when we focuse on a
4651 * window that isn't fullscreen but has clone.y 0 ==> need a layout call.
4652 */
4653 if (
4654 metaWindow.clone.y === 0 &&

Callers 2

registerWindowFunction · 0.85
insertWindowFunction · 0.85

Calls 15

setAllWorkspacesInactiveFunction · 0.85
isTransientFunction · 0.85
ensureViewportFunction · 0.85
spaceOfWindowMethod · 0.80
hideSelectionMethod · 0.80
getWindowsMethod · 0.80
hasFullScreenWindowMethod · 0.80
showSelectionMethod · 0.80
indexOfMethod · 0.80
raiseMethod · 0.80

Tested by

no test coverage detected