Skip to content

Commit e49a997

Browse files
committed
windowMenu.js: Never allow more than one menu at a time.
Keep track of the menu we make, and destroy it before making another.
1 parent 7c88463 commit e49a997

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

js/ui/windowMenu.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,18 @@ var WindowMenuManager = class {
376376
this.dummyCursor = new St.Widget({ width: 0, height: 0, opacity: 0 });
377377
Main.uiGroup.add_actor(this.dummyCursor);
378378
this.actor = this.dummyCursor;
379+
380+
this.current_menu = null;
381+
this.current_window = null;
382+
this.destroyId = 0;
379383
}
380384

381385
showWindowMenuForWindow(window, type, rect) {
382386
if (type != Meta.WindowMenuType.WM)
383387
throw new Error('Unsupported window menu type');
388+
389+
this.destroyMenu();
390+
384391
let menu = new WindowMenu(window, this._sourceActor);
385392

386393
this._manager.addMenu(menu);
@@ -389,11 +396,11 @@ var WindowMenuManager = class {
389396
window.check_alive(global.get_current_time());
390397
});
391398
menu.connect('menu-animated-closed', () => {
392-
menu.destroy()
399+
this.destroyMenu();
393400
});
394401

395402
let destroyId = window.connect('unmanaged', () => {
396-
menu.close();
403+
this.destroyMenu();
397404
});
398405

399406
this._sourceActor.set_size(Math.max(1, rect.width), Math.max(1, rect.height));
@@ -407,11 +414,24 @@ var WindowMenuManager = class {
407414
menu.open();
408415
menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
409416
menu.connect('open-state-changed', (menu_, isOpen) => {
410-
if (isOpen)
411-
return;
412-
413-
this._sourceActor.hide();
414-
window.disconnect(destroyId);
417+
this.destroyMenu();
415418
});
419+
420+
this.current_menu = menu;
421+
this.current_window = window;
422+
}
423+
424+
destroyMenu() {
425+
this._sourceActor.hide();
426+
427+
if (this.destroyId > 0) {
428+
this.current_window.disconnect(destroyId);
429+
this.destroyId = 0;
430+
}
431+
432+
if (this.current_menu) {
433+
this.current_menu.destroy();
434+
this.current_menu = null;
435+
}
416436
}
417437
};

0 commit comments

Comments
 (0)