Skip to content
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

Dynamic monitors #56

Closed
zoriya opened this issue Aug 23, 2023 · 4 comments
Closed

Dynamic monitors #56

zoriya opened this issue Aug 23, 2023 · 4 comments

Comments

@zoriya
Copy link
Contributor

zoriya commented Aug 23, 2023

All windows have to be defined inside the windows array of the default export of config.js, and we can't register new windows at runtime (I think). I would like to automatically create new bars for newly plugged in monitors so to do that ags should either:

  • Support a monitor factory method in the config that would create a list of windows for a given monitor id/name.
  • Support dynamic windows creation via a connect or an event to a service that will be notified when a monitor is created/destroyed.
@Aylur
Copy link
Owner

Aylur commented Aug 23, 2023

Its true you can't register new windows at runtime, but you can definitely make new ones with just calling ags.Widget.Window, and you can use Gdk.Display signals to watch for monitors.
This feature sounds useful, I will integrate something into ags.App

@Aylur
Copy link
Owner

Aylur commented Aug 23, 2023

Added the option to register windows on runtime. Now it is also possible to pass a Gdk.Monitor to ags.Widget.Window
so the emitted monitors from Gdk.Display signals can be used

Aylur added a commit that referenced this issue Aug 23, 2023
@Aylur
Copy link
Owner

Aylur commented Aug 23, 2023

you can also get the monitor associated with each window, so it can be removed on Gdk.Display signal

@Aylur
Copy link
Owner

Aylur commented Aug 23, 2023

// example
const display = imports.gi.Gdk.Display.get_default();
display.connect('monitor-added', (_, monitor) => {
    const win = ags.Widget.Window({
        name: 'test',
        child: ags.Widget.Label('test'),
        monitor,
    });

    ags.App.addWindow(win);
});
display.connect('monitor-removed', (_, monitor) => {
    for (const [name, win] of ags.App.windows) {
        if (win.monitor == monitor)
            ags.App.removeWindow(name);
    }
});

you will still have to makes sure that Window.name is unique

@Aylur Aylur closed this as completed Aug 23, 2023
ferrreo pushed a commit to ferrreo/ags that referenced this issue Aug 24, 2023
ferrreo pushed a commit to ferrreo/ags that referenced this issue Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants