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

Method monitorsChanged

tiling.js:2260–2422  ·  view source on GitHub ↗

The monitors-changed signal can trigger _many_ times when connection/disconnecting monitors. Monitors are now upgraded via a dbus proxy connector which upgrades Main.layoutManager.monitors with a "connector" property (e.g "eDP-1") which is more stable for restoring monit

()

Source from the content-addressed store, hash-verified

2258 which is more stable for restoring monitor layouts.
2259 */
2260 monitorsChanged() {
2261 this.onlyOnPrimary = this.overrideSettings.get_boolean('workspaces-only-on-primary');
2262 this.monitors = new Map();
2263
2264 // can be called async (after delay) on disable - use activeSpace as check
2265 if (!this.activeSpace) {
2266 return;
2267 }
2268
2269 this.activeSpace.getWindows().forEach(w => {
2270 animateWindow(w);
2271 });
2272
2273 this.spaceContainer.set_size(global.screen_width, global.screen_height);
2274
2275 for (let overlay of this.clickOverlays) {
2276 overlay.destroy();
2277 }
2278 this.clickOverlays = [];
2279 let mru = this.mru();
2280
2281 let primary = Main.layoutManager.primaryMonitor;
2282 if (!primary) {
2283 // setup periodic timout to call layout on all spaces 5 times (1 second apart)
2284 monitorChangeTimeout = Utils.periodic_timeout({
2285 count: 5,
2286 init: () => {
2287 Utils.timeout_remove(monitorChangeTimeout);
2288 },
2289 callback: () => {
2290 this?.forEach(s => s.layout());
2291 },
2292 onContinue: called => {
2293 console.warn(`MONITORS_CHANGED: no primary monitor - 'layout' on spaces call ${called}`);
2294 },
2295 onComplete: () => {
2296 monitorChangeTimeout = null;
2297 },
2298 });
2299 return;
2300 }
2301
2302 // get monitors but ensure primary monitor is first
2303 let monitors = Main.layoutManager.monitors.filter(m => m !== primary);
2304 monitors.unshift(primary);
2305
2306 for (let monitor of monitors) {
2307 let overlay = new ClickOverlay(monitor, this.onlyOnPrimary);
2308 monitor.clickOverlay = overlay;
2309 this.clickOverlays.push(overlay);
2310 }
2311
2312 let finish = () => {
2313 /**
2314 * Gnome may select a workspace that just had it monitor removed (gone).
2315 * This this case find the next most recent space that's maintained it's
2316 * monitor, and select that.
2317 */

Callers 1

initMethod · 0.95

Calls 13

destroyMethod · 0.95
mruMethod · 0.95
setMonitorsMethod · 0.95
spaceOfUuidMethod · 0.95
spaceOfIndexMethod · 0.95
animateWindowFunction · 0.85
getWindowsMethod · 0.80
setMonitorMethod · 0.80
hasPrevTargetXMethod · 0.80
viewportMoveToXMethod · 0.80
hasPrevMonitorsMethod · 0.80
layoutMethod · 0.45

Tested by

no test coverage detected