MCPcopy Index your code
hub / github.com/material-shell/material-shell / trackAppChanges

Method trackAppChanges

src/layout/msWorkspace/msWindow.ts:328–366  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

326 }
327
328 private trackAppChanges() {
329 assert(
330 this.appSignalId === undefined,
331 'Expected the signalId to be undefined'
332 );
333 this.appSignalId = this.app.connect('windows-changed', () => {
334 const lifecycleState = this.lifecycleState;
335 if (lifecycleState.type === 'window') {
336 const metaWindowList = this.app.get_windows();
337 if (
338 lifecycleState.metaWindow &&
339 !metaWindowList.includes(lifecycleState.metaWindow)
340 ) {
341 // We have to wait next cycle to get the proper app
342 GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
343 // Guard to ensure the lifecycle state has not changed before the callback was called
344 if (
345 this.lifecycleState == lifecycleState &&
346 lifecycleState.metaWindow
347 ) {
348 const app =
349 Shell.WindowTracker.get_default().get_window_app(
350 lifecycleState.metaWindow
351 );
352 if (app !== null) {
353 this.app.disconnect(
354 assertNotNull(this.appSignalId)
355 );
356 this.appSignalId = undefined;
357 this.app = app;
358 this.onAppChanged();
359 }
360 }
361 return GLib.SOURCE_REMOVE;
362 });
363 }
364 }
365 });
366 }
367
368 private onAppChanged() {
369 const state = this.lifecycleState;

Callers 2

constructorMethod · 0.95
onAppChangedMethod · 0.95

Calls 8

onAppChangedMethod · 0.95
assertFunction · 0.90
assertNotNullFunction · 0.90
get_window_appMethod · 0.80
get_defaultMethod · 0.80
connectMethod · 0.65
get_windowsMethod · 0.65
disconnectMethod · 0.65

Tested by

no test coverage detected