Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

/**
Expand Down Expand Up @@ -581,7 +585,7 @@ function onAddEffect(actor) {
logDbg(` → skipped`);
return;
}

const target = targetActor(actor);
if (!target) return;

Expand All @@ -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 = [];
Expand All @@ -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 {
Expand All @@ -625,22 +646,14 @@ 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
}

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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down