diff --git a/extension.js b/extension.js index 9f4f976..4ddabed 100644 --- a/extension.js +++ b/extension.js @@ -305,7 +305,11 @@ function getWindowTexture(actor) { /** Get the RoundedCornersEffect attached to a window actor (or null). */ function getEffect(actor) { const target = targetActor(actor); - return target ? target.get_effect(ROUNDED_CORNERS_EFFECT) : null; + try { + return target ? target.lastChild.get_effect(ROUNDED_CORNERS_EFFECT) : null; + } catch (e) { + return null + } } /** @@ -581,7 +585,7 @@ function onAddEffect(actor) { logDbg(` → skipped`); return; } - + const target = targetActor(actor); if (!target) return; @@ -590,7 +594,7 @@ function onAddEffect(actor) { return; } - target.add_effect_with_name(ROUNDED_CORNERS_EFFECT, new RoundedCornersEffect()); + target.get_last_child()?.add_effect_with_name(ROUNDED_CORNERS_EFFECT, new RoundedCornersEffect()); let shadow = null; let bindings = []; @@ -616,6 +620,23 @@ function onAddEffect(actor) { refreshRoundedCorners(actor); } +function disconnectSignal(actor){ + try { + logDbg(`Removing signals from "${actor.metaWindow?.title}"`); + } catch (_) {} + + const data = _actorMap.get(actor); + if (!data) return; + + // Disconnect per-window signals safely + if (data.connections) { + for (const c of data.connections) { + try { c.obj.disconnect(c.id); } catch (_) {} + } + data.connections = []; + } +} + /** Remove effects and shadow from a window actor. */ function onRemoveEffect(actor) { try { @@ -625,7 +646,7 @@ function onRemoveEffect(actor) { try { const target = targetActor(actor); if (target) - target.remove_effect_by_name(ROUNDED_CORNERS_EFFECT); + target.get_last_child()?.remove_effect_by_name(ROUNDED_CORNERS_EFFECT); } catch (_) { // Actor may already be destroyed } @@ -633,14 +654,6 @@ function onRemoveEffect(actor) { const data = _actorMap.get(actor); if (!data) return; - // Disconnect per-window signals safely - if (data.connections) { - for (const c of data.connections) { - try { c.obj.disconnect(c.id); } catch (_) {} - } - data.connections = []; - } - // Unbind property mirrors for (const b of data.bindings) b.unbind(); @@ -785,6 +798,9 @@ function attachWindowSignals(actor) { // Fullscreen state changed (may not cause a size change) addWinConn(win, 'notify::fullscreen', () => { if (actor.metaWindow) refreshRoundedCorners(actor); }); + // Maximized state changed (may not cause a size change) + addWinConn(win, 'notify::maximized-horizontally', () => { if (actor.metaWindow) refreshRoundedCorners(actor); }); + addWinConn(win, 'notify::maximized-vertically', () => { if (actor.metaWindow) refreshRoundedCorners(actor); }); // Focus changed → update shadow style addWinConn(win, 'notify::appears-focused',() => { if (actor.metaWindow) refreshFocus(actor); }); // Monitor / workspace change @@ -827,6 +843,19 @@ function applyEffectTo(actor) { return; } + // make sure that the actor is not a bms-application-blurred-widget. + const bmsActorName = 'bms-application-blurred-widget'; + const actorReady = (actor.firstChild && actor.firstChild.name !== bmsActorName) || + (actor.lastChild && actor.lastChild.name !== bmsActorName); + if (!actorReady) { + const id = actor.connect('child-added', (actor, child) => { + if (child.name !== bmsActorName) { + applyEffectTo(actor); + actor.disconnect(id); + } + }); +} + // Add the effect FIRST, then connect signals. If signals were connected // before the effect, adding the effect could trigger notify::size // synchronously, causing re-entrant calls to refreshRoundedCorners @@ -877,7 +906,10 @@ function enableEffect() { // Window closed addConnection(global.windowManager, 'destroy', - (_, actor) => removeEffectFrom(actor)); + (_, actor) => { + disconnectSignal(actor); + removeEffectFrom(actor) + }); // Minimise: always hide shadow + disable effect to prevent the white // background of the shadow actor from showing during the animation.