@@ -440,49 +440,67 @@ bool WayfirePanelApp::panel_allowed_by_config(bool allowed, std::string output_n
440440 }
441441}
442442
443- void WayfirePanelApp::on_activate ()
443+ void WayfirePanelApp::update_panels ()
444444{
445- WayfireShellApp::on_activate ();
446-
447- priv->panel_outputs ->set_callback ([=] ()
445+ /* First case: Panel exists on the output but is not allowed by config: Remove panel */
446+ for (auto & o : *get_wayfire_outputs ())
448447 {
449- /* First case: Panel exists on the output but is not allowed by config: Remove panel */
450- for (auto & o : *get_wayfire_outputs ())
448+ auto output = o.get ();
449+ auto output_name = o->monitor ->get_connector ();
450+ if (panel_allowed_by_config (false , output_name))
451451 {
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- }
452+ std::cout << " Removing panel from output: " << output_name << std::endl;
453+ priv->panels .erase (output);
459454 }
455+ }
460456
461- /* Second case: Panel does 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 ();
457+ /* Second case: Panel does not exist for the output but is allowed by config: Add panel */
458+ for (auto & o : *get_wayfire_outputs ())
459+ {
460+ auto output = o.get ();
461+ auto output_name = o->monitor ->get_connector ();
466462
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- });
463+ const auto it = std::find_if (priv->panels .begin (), priv->panels .end (),
464+ [&output_name] (const auto & panel)
465+ {
466+ return panel.first ->monitor ->get_connector () == output_name;
467+ });
472468
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));
469+ if ((it == priv->panels .end ()) && panel_allowed_by_config (true , output_name))
470+ {
471+ std::cout << " Adding panel for output: " << output_name << std::endl;
472+ priv->panels [output] = std::unique_ptr<WayfirePanel>(
473+ new WayfirePanel (output));
474+ }
475+ }
478476
479- priv->panels [output]->handle_config_reload ();
480- priv->panels [output]->set_panel_app (this );
481- priv->panels [output]->init_widgets ();
482- }
477+ if (ipc_server)
478+ {
479+ for (auto & p : priv->panels )
480+ {
481+ p.second ->handle_config_reload ();
482+ p.second ->set_panel_app (this );
483+ p.second ->init_widgets ();
483484 }
485+ }
486+ }
487+
488+ void WayfirePanelApp::on_activate ()
489+ {
490+ WayfireShellApp::on_activate ();
491+
492+ priv->panel_outputs ->set_callback ([=] ()
493+ {
494+ update_panels ();
484495 });
485496
497+ if (!ipc_server)
498+ {
499+ ipc_server = WayfireIPC::get_instance ();
500+ }
501+
502+ update_panels ();
503+
486504 if (priv->panels .empty ())
487505 {
488506 std::cout << std::endl <<
@@ -526,13 +544,6 @@ void WayfirePanelApp::on_activate()
526544 new CssFromConfigFont (" panel/battery_font" , " .battery {" , " }" );
527545 new CssFromConfigFont (" panel/clock_font" , " .clock {" , " }" );
528546 new CssFromConfigFont (" panel/weather_font" , " .weather {" , " }" );
529-
530- ipc_server = WayfireIPC::get_instance ();
531- for (auto & p : priv->panels )
532- {
533- p.second ->set_panel_app (this );
534- p.second ->init_widgets ();
535- }
536547}
537548
538549std::shared_ptr<WayfireIPC> WayfirePanelApp::get_ipc_server_instance ()
@@ -542,12 +553,7 @@ std::shared_ptr<WayfireIPC> WayfirePanelApp::get_ipc_server_instance()
542553
543554void WayfirePanelApp::handle_new_output (WayfireOutput *output)
544555{
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- }
556+ update_panels ();
551557}
552558
553559WayfirePanel*WayfirePanelApp::panel_for_wl_output (wl_output *output)
0 commit comments