Skip to content

Comments

panel: Add outputs option for per-output configuration#356

Open
soreau wants to merge 1 commit intomasterfrom
panel-outputs
Open

panel: Add outputs option for per-output configuration#356
soreau wants to merge 1 commit intomasterfrom
panel-outputs

Conversation

@soreau
Copy link
Member

@soreau soreau commented Feb 21, 2026

This adds a new option named 'outputs' that is a list of output names on which a panel instance should be rendered. The default value is '*' wildcard, which means all outputs.

@soreau soreau marked this pull request as draft February 21, 2026 18:59
@soreau soreau marked this pull request as ready for review February 21, 2026 19:05
public:
std::map<WayfireOutput*, std::unique_ptr<WayfirePanel>> panels;
std::map<std::string, WayfireOutput*> outputs;
WfOption<std::string> *panel_outputs;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this dynamically allocated seems really weird, if you need to load an option at runtime, you can use .load_option(<option name>)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like this might work.

* because an '*' character was found in the panel_outputs string */
if (std::string(*priv->panel_outputs).find("*") != std::string::npos)
{
for (auto& o : priv->outputs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a separate map from string to a WayfireOutput ? If we want to iterate over all outputs, I believe gdk has a function for this (https://docs.gtk.org/gdk4/method.Display.get_monitors.html)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you need the WayfireOutput to create the panel. You cannot get this from the gdk function, unless you make the wf-shell-app monitors list public, as far as I understand.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like we should add a getter then. The less overall state, the better IMO. Considering we already keep it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A getter would incur looping each time we call the function and would require modifying code outside of panel.cpp, if I am thinking about this right. A std::map is more efficient here and keeps the patch clean.

return;
}

/* Second case: Add a panel for each output in the panel_outputs string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe a simpler algorithm would be like this in pseudocode:

for_each_existing_panel:
    if output not allowed in config:
        remove panel

for_each_gdk_monitor:
    if output allowed in config and does not have panel:
        create panel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way I believe you won't need any of the new maps you have added, and I have found that generally the less state you have, the less possibilities for things to go wrong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the pseudo code you have is flawed simply because we do not want to unnecessarily recreate panels, since that will reorder the window-list and reset other widgets.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how it is flawed, because I say to create a panel if it does NOT exist already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's not very different from what I have so far, I'm sure there are many other ways to skin this cat though.

new WayfirePanel(output));
priv->panel_outputs = new WfOption<std::string>{"panel/outputs"};
priv->outputs[output->monitor->get_connector()] = output;
if ((std::string(*priv->panel_outputs).find("*") != std::string::npos) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have these checks everywhere, I think it would make sense to add a function is_panel_enabled_in_config(config_opt, output_name)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be doable, but it's really only two cases where we'd need it, if I am thinking correctly.

This adds a new option named 'outputs' that is a comma separated list
of output names on which a panel instance should be rendered. The
default value is '*' wildcard, which means all outputs.
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

Successfully merging this pull request may close these issues.

2 participants