Merge branch 'fix-legacy-tray-icons' into 'main'

fix: legacy tray icons and empty top bar after unlocking

See merge request june/top-bar-organizer!6
This commit is contained in:
Michał Tatarynowicz 2026-11-09 09:30:57 +00:00
commit e79e7fb550
2 changed files with 26 additions and 12 deletions

View file

@ -54,18 +54,21 @@ export default class TopBarOrganizerExtension extends Extension {
} }
disable(): void { disable(): void {
// Revert the overwrite of `Panel._addToPanelBox`. // Revert the overwrite of `Panel._addToPanelBox`, if there is one.
// @ts-ignore
if (Panel.Panel.prototype._originalAddToPanelBox) {
// @ts-ignore // @ts-ignore
Panel.Panel.prototype._addToPanelBox = Panel.Panel.prototype._originalAddToPanelBox; Panel.Panel.prototype._addToPanelBox = Panel.Panel.prototype._originalAddToPanelBox;
// Set `Panel._originalAddToPanelBox` to `undefined`. // Set `Panel._originalAddToPanelBox` to `undefined`.
// @ts-ignore // @ts-ignore
Panel.Panel.prototype._originalAddToPanelBox = undefined; Panel.Panel.prototype._originalAddToPanelBox = undefined;
// Disconnect signals.
for (const handlerId of this._settingsHandlerIds) {
this._settings.disconnect(handlerId);
} }
this._boxOrderManager.disconnectSignals();
// Disconnect signals. `enable()` may not have got this far.
for (const handlerId of this._settingsHandlerIds ?? []) {
this._settings?.disconnect(handlerId);
}
this._boxOrderManager?.disconnectSignals();
// @ts-ignore // @ts-ignore
this._settings = null; this._settings = null;
@ -83,9 +86,16 @@ export default class TopBarOrganizerExtension extends Extension {
*/ */
#overwritePanelAddToPanelBox(): void { #overwritePanelAddToPanelBox(): void {
// Add the original `Panel._addToPanelBox` method as // Add the original `Panel._addToPanelBox` method as
// `Panel._originalAddToPanelBox`. // `Panel._originalAddToPanelBox`, unless it's already saved. That is
// the case when an earlier `enable()` failed, so `disable()` never
// ran: `Panel._addToPanelBox` is then still our overwrite, and saving
// that as the original would make it call itself endlessly, which
// leaves the top bar empty.
// @ts-ignore
if (!Panel.Panel.prototype._originalAddToPanelBox) {
// @ts-ignore // @ts-ignore
Panel.Panel.prototype._originalAddToPanelBox = Panel.Panel.prototype._addToPanelBox; Panel.Panel.prototype._originalAddToPanelBox = Panel.Panel.prototype._addToPanelBox;
}
const handleNewItemsAndOrderTopBar = () => { const handleNewItemsAndOrderTopBar = () => {
this.#handleNewItemsAndOrderTopBar(); this.#handleNewItemsAndOrderTopBar();

View file

@ -338,10 +338,14 @@ export default class BoxOrderManager extends GObject.Object {
// Then get a settings identifier for the item. // Then get a settings identifier for the item.
let itemSettingsId; let itemSettingsId;
if (role.startsWith("appindicator-")) { if (role.startsWith("appindicator-") &&
(indicatorContainer.get_child() as any)?._indicator) {
// If the role indicates that the item is an // If the role indicates that the item is an
// AppIndicator/KStatusNotifierItem item, then handle it // AppIndicator/KStatusNotifierItem item, then handle it
// differently. // differently.
// Legacy (XEmbed) tray icons added by the same extension
// also get an "appindicator-" role, but have no
// _indicator, so they're treated like any other item.
try { try {
itemSettingsId = this.#handleAppIndicatorItem(indicatorContainer, role); itemSettingsId = this.#handleAppIndicatorItem(indicatorContainer, role);
} catch (e) { } catch (e) {