Aylur / astal

Building blocks for creating custom desktop shells
https://aylur.github.io/astal/
GNU Lesser General Public License v2.1
279 stars 35 forks source link

Windows not visible after a monitor power cycle #99

Closed noib3 closed 1 week ago

noib3 commented 1 week ago

Describe the bug

Astal windows disapper after a monitor is turned off.

To Reproduce

I'm using a single external monitor. I'm not sure if it can be reproduced on a laptop by closing and opening the lid.

Expected behavior

The bar is still visible after the monitor is turned back on.

kotontrion commented 1 week ago

When you power off your monitor it will be disconnected. Windows bound to a specific monitor will get destroyed when that monitor gets disconnected. Not destroying that window would violate the layer shell protocol and is done automatically by the gtk-layer-shell library.

You need to connect to the monitor added and removed events to recreate the windows:

        //create windows for already connected monitors
        App.get_monitors().map(Bar)
        //create windows for newly connected monitors
        App.connect("monitor_added", (_, mon) => Bar(mon))
       //remove windows for removed monitors
        App.connect("monitor_removed", (_, mon) => {
            App.get_windows().forEach(w => {
                if(w.gdkmonitor == mon) App.remove_window(w)
            })
        })
Aylur commented 1 week ago

https://aylur.github.io/astal/guide/typescript/faq#auto-create-window-for-each-monitor