@@ -411,20 +411,96 @@ class WayfirePanelApp::impl
411411{
412412 public:
413413 std::map<WayfireOutput*, std::unique_ptr<WayfirePanel>> panels;
414+ WfOption<std::string> *panel_outputs = NULL ;
414415};
415416
416417void WayfirePanelApp::on_config_reload ()
417418{
419+ if (!priv->panel_outputs )
420+ {
421+ priv->panel_outputs = new WfOption<std::string>(" panel/outputs" );
422+ }
423+
418424 for (auto & p : priv->panels )
419425 {
420426 p.second ->handle_config_reload ();
421427 }
422428}
423429
430+ bool WayfirePanelApp::panel_allowed_by_config (bool allowed, std::string output_name)
431+ {
432+ if (allowed)
433+ {
434+ return std::string (*priv->panel_outputs ).find (" *" ) != std::string::npos ||
435+ std::string (*priv->panel_outputs ).find (output_name) != std::string::npos;
436+ } else
437+ {
438+ return std::string (*priv->panel_outputs ).find (" *" ) == std::string::npos &&
439+ std::string (*priv->panel_outputs ).find (output_name) == std::string::npos;
440+ }
441+ }
442+
424443void WayfirePanelApp::on_activate ()
425444{
426445 WayfireShellApp::on_activate ();
427446
447+ priv->panel_outputs ->set_callback ([=] ()
448+ {
449+ /* First case: Panel exists on the output but is not allowed by config: Remove panel */
450+ for (auto & o : *get_wayfire_outputs ())
451+ {
452+ auto output = o.get ();
453+ auto output_name = o->monitor ->get_connector ();
454+ if (panel_allowed_by_config (false , output_name))
455+ {
456+ std::cout << " Removing panel from output: " << output_name << std::endl;
457+ priv->panels .erase (output);
458+ }
459+ }
460+
461+ /* Second case: Panel doe not exist for the output but is allowed by config: Add panel */
462+ for (auto & o : *get_wayfire_outputs ())
463+ {
464+ auto output = o.get ();
465+ auto output_name = o->monitor ->get_connector ();
466+
467+ const auto it = std::find_if (priv->panels .begin (), priv->panels .end (),
468+ [&output_name] (const auto & panel)
469+ {
470+ return panel.first ->monitor ->get_connector () == output_name;
471+ });
472+
473+ if ((it == priv->panels .end ()) && panel_allowed_by_config (true , output_name))
474+ {
475+ std::cout << " Adding panel for output: " << output_name << std::endl;
476+ priv->panels [output] = std::unique_ptr<WayfirePanel>(
477+ new WayfirePanel (output));
478+
479+ priv->panels [output]->handle_config_reload ();
480+ priv->panels [output]->set_panel_app (this );
481+ priv->panels [output]->init_widgets ();
482+ }
483+ }
484+ });
485+
486+ if (priv->panels .empty ())
487+ {
488+ std::cout << std::endl <<
489+ " WARNING: wf-panel outputs option did not match any outputs, " \
490+ " so none were created. Set the [panel] outputs option to * " \
491+ " wildcard character in wf-shell configuariton file to match " \
492+ " all outputs, or set one or more of the following detected outputs:" <<
493+ std::endl << std::endl;
494+
495+ for (auto & o : *get_wayfire_outputs ())
496+ {
497+ std::cout << o->monitor ->get_connector () << std::endl;
498+ }
499+
500+ std::cout << std::endl << " Currently the [panel] outputs option is set to: " <<
501+ std::string (*priv->panel_outputs ) << std::endl;
502+ }
503+
428504 const static std::vector<std::pair<std::string, std::string>> icon_sizes_args =
429505 {
430506 {" panel/minimal_height" , " " },
@@ -466,8 +542,12 @@ std::shared_ptr<WayfireIPC> WayfirePanelApp::get_ipc_server_instance()
466542
467543void WayfirePanelApp::handle_new_output (WayfireOutput *output)
468544{
469- priv->panels [output] = std::unique_ptr<WayfirePanel>(
470- new WayfirePanel (output));
545+ if (panel_allowed_by_config (true , output->monitor ->get_connector ()))
546+ {
547+ std::cout << " Adding panel for output: " << output->monitor ->get_connector () << std::endl;
548+ priv->panels [output] = std::unique_ptr<WayfirePanel>(
549+ new WayfirePanel (output));
550+ }
471551}
472552
473553WayfirePanel*WayfirePanelApp::panel_for_wl_output (wl_output *output)
0 commit comments