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

Method setMonitor

tiling.js:1986–2044  ·  view source on GitHub ↗
(monitor, animate = false, options = {})

Source from the content-addressed store, hash-verified

1984 }
1985
1986 setMonitor(monitor, animate = false, options = {}) {
1987 const commit = options?.commit ?? true;
1988
1989 // check monitor exists
1990 if (!monitor) {
1991 return;
1992 }
1993
1994 // Remake the background when we move monitors. The size/scale will be
1995 // incorrect when using fractional scaling.
1996 if (monitor !== this.monitor) {
1997 if (commit) {
1998 this.monitor = monitor;
1999 }
2000 this.createBackground();
2001 this.updateColor();
2002 this.updateBackground();
2003
2004 // update width of windowPositonBarBackdrop (to match monitor)
2005 this.windowPositionBarBackdrop.width = monitor.width;
2006 }
2007
2008 let background = this.background;
2009 let clip = this.clip;
2010
2011 this.width = monitor.width;
2012 this.height = monitor.height;
2013
2014 let time = animate ? Settings.prefs.animation_time : 0;
2015
2016 Easer.addEase(this.actor,
2017 {
2018 x: 0, y: 0, scale_x: 1, scale_y: 1,
2019 time,
2020 });
2021 Easer.addEase(clip,
2022 { scale_x: 1, scale_y: 1, time });
2023
2024 clip.set_position(monitor.x, monitor.y);
2025 clip.set_size(monitor.width, monitor.height);
2026 clip.set_clip(0, 0,
2027 monitor.width,
2028 monitor.height);
2029
2030 let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
2031 this.border.set_position(-borderWidth * scale, -borderWidth * scale);
2032 this.border.set_size(monitor.width + scale * borderWidth * 2,
2033 monitor.height + scale * borderWidth * 2);
2034
2035 background.set_size(this.width, this.height);
2036
2037 this.cloneClip.set_size(monitor.width, monitor.height);
2038 this.cloneClip.set_clip(0, 0, this.width, this.height);
2039 // transforms break if there's no height
2040 this.cloneContainer.height = this.monitor.height;
2041
2042 this.layout(true, { centerIfOne: false });
2043 this.emit('monitor-changed');

Callers 9

constructorMethod · 0.95
destroyMethod · 0.80
monitorsChangedMethod · 0.80
_updateMonitorMethod · 0.80
switchWorkspaceMethod · 0.80
selectSequenceSpaceMethod · 0.80
initWorkspaceStackMethod · 0.80
moveToFunction · 0.80

Calls 4

createBackgroundMethod · 0.95
updateColorMethod · 0.95
updateBackgroundMethod · 0.95
layoutMethod · 0.95

Tested by

no test coverage detected