Skip to content

Improve Blur-My-Shell compatibility #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 7 additions & 6 deletions src/manager/event_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
getRoundedCornersCfg,
getRoundedCornersEffect,
shouldEnableEffect,
unwrapActor,
updateShadowActorStyle,
windowScaleFactor,
} from './utils.js';
Expand All @@ -43,10 +42,12 @@ export function onAddEffect(actor: RoundedWindowActor) {
return;
}

unwrapActor(actor)?.add_effect_with_name(
ROUNDED_CORNERS_EFFECT,
new RoundedCornersEffect(),
);
actor
.get_last_child()
?.add_effect_with_name(
ROUNDED_CORNERS_EFFECT,
new RoundedCornersEffect(),
);

const shadow = createShadow(actor);

Expand Down Expand Up @@ -80,7 +81,7 @@ export function onAddEffect(actor: RoundedWindowActor) {

export function onRemoveEffect(actor: RoundedWindowActor): void {
const name = ROUNDED_CORNERS_EFFECT;
unwrapActor(actor)?.remove_effect_by_name(name);
actor.get_last_child()?.remove_effect_by_name(name);

// Remove shadow actor
const shadow = actor.rwcCustomData?.shadow;
Expand Down
18 changes: 14 additions & 4 deletions src/manager/event_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,20 @@ function applyEffectTo(actor: RoundedWindowActor) {
// In wayland sessions, the surface actor of XWayland clients is sometimes
// not ready when the window is created. In this case, we wait until it is
// ready before applying the effect.
if (!actor.firstChild) {
const id = actor.connect('notify::first-child', () => {
applyEffectTo(actor);
actor.disconnect(id);
// For Blur My Shell compatibility, we have to make sure that the actor is
// not a bms-application-blurred-widget. This actor is created by BMS and
// is not the actual window actor.
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);
}
});

return;
Expand Down
18 changes: 1 addition & 17 deletions src/manager/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ import type Clutter from 'gi://Clutter';
import type {RoundedCornersEffect} from '../effect/rounded_corners_effect.js';
import type {Bounds, RoundedCornerSettings} from '../utils/types.js';

/**
* Get the actor that rounded corners should be applied to.
* In Wayland, the effect is applied to WindowActor, but in X11, it is applied
* to WindowActor.first_child.
*
* @param actor - The window actor to unwrap.
* @returns The correct actor that the effect should be applied to.
*/
export function unwrapActor(actor: Meta.WindowActor): Clutter.Actor | null {
const type = actor.metaWindow.get_client_type();
return type === Meta.WindowClientType.X11 ? actor.get_first_child() : actor;
}

/**
* Get the correct rounded corner setting for a window (custom settings if a
* window has custom overrides, global settings otherwise).
Expand Down Expand Up @@ -67,11 +54,8 @@ type RoundedCornersEffectType = InstanceType<typeof RoundedCornersEffect>;
export function getRoundedCornersEffect(
actor: Meta.WindowActor,
): RoundedCornersEffectType | null {
const win = actor.metaWindow;
const name = ROUNDED_CORNERS_EFFECT;
return win.get_client_type() === Meta.WindowClientType.X11
? (actor.firstChild.get_effect(name) as RoundedCornersEffectType)
: (actor.get_effect(name) as RoundedCornersEffectType);
return actor.lastChild.get_effect(name) as RoundedCornersEffectType;
}

/**
Expand Down