I am working on a gnome extension. I am trying to put border around windows.
_add_orange_border_to_window = function (win) {
if (!win) return;
let actor = win.get_compositor_private().get_parent();
if (!actor) return;
if (!borders[win]) {
borders[win] = new St.Bin({
style_class: 'border'
});
actor.add_child(borders[win]);
}
const BORDERSIZE = 3;
function redrawBorder() {
let rect = win.get_frame_rect();
borders[win].set_position(rect.x - BORDERSIZE, rect.y - BORDERSIZE);
borders[win].set_size(rect.width + 2 * BORDERSIZE, rect.height + 2 * BORDERSIZE);
}
function restack(display){
actor.get_children().forEach(
(child) => {
let sibling = Meta.get_window_group_for_display(display);
sibling.set_child_above_sibling(actor, this);
}
)
}
redrawBorder();
// Connect to the size-changed and position-changed signals
signalHandlers[win] = {
sizeChangedId: win.connect('size-changed', redrawBorder),
positionChangedId: win.connect('position-changed', redrawBorder),
restackHandlerID : Display.connect('restacked', restack),
unmanagedId: win.connect('unmanaged', () => {
actor.remove_child(borders[win]);
win.disconnect(signalHandlers[win].sizeChangedId);
win.disconnect(signalHandlers[win].positionChangedId);
win.disconnect(signalHandlers[win].restackHandlerID);
win.disconnect(signalHandlers[win].unmanagedId);
delete borders[win];
delete signalHandlers[win];
})
};
}
This code works. But there is an issue. When drawing multiple borders all the borders seems to be on top of all the windows.
I have checked Adding color to borders gnome windows. It says:
That’s because the borders aren’t actually windows. The compositor has no idea where to put them in the stack, so ignores them.
You have to move them to the right layer yourself, and connect to the global.display('restacked') signal to update them.
There is also a working code there.
But I could not figure out what to do. The given code is all i have managed so far and it is giving rectangles on top of all the windows.
What can I do?

global.window_group.set_child_above_sibling(window.border, child)in that code looks like it does what you want.global.window_group, but could not get it to work.