()
| 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; |
no test coverage detected