@@ -440,49 +440,69 @@ 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 ())
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 ();
462+
463+ const auto it = std::find_if (priv->panels .begin (), priv->panels .end (),
464+ [&output_name] (const auto & panel)
463465 {
464- auto output = o. get () ;
465- auto output_name = o-> monitor -> get_connector ( );
466+ return panel. first -> monitor -> get_connector () == output_name ;
467+ } );
466468
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- } );
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) );
472474
473- if ((it == priv-> panels . end ()) && panel_allowed_by_config ( true , output_name) )
475+ if (ipc_server )
474476 {
475- std::cout << " Adding panel for output: " << output_name << std::endl;
476- priv->panels [output] = std::unique_ptr<WayfirePanel>(
477- new WayfirePanel (output));
478-
479477 priv->panels [output]->handle_config_reload ();
480478 priv->panels [output]->set_panel_app (this );
481479 priv->panels [output]->init_widgets ();
482480 }
483481 }
482+ }
483+ }
484+
485+ void WayfirePanelApp::on_activate ()
486+ {
487+ WayfireShellApp::on_activate ();
488+
489+ priv->panel_outputs ->set_callback ([=] ()
490+ {
491+ update_panels ();
484492 });
485493
494+ if (!ipc_server)
495+ {
496+ ipc_server = WayfireIPC::get_instance ();
497+ }
498+
499+ for (auto & p : priv->panels )
500+ {
501+ p.second ->handle_config_reload ();
502+ p.second ->set_panel_app (this );
503+ p.second ->init_widgets ();
504+ }
505+
486506 if (priv->panels .empty ())
487507 {
488508 std::cout << std::endl <<
@@ -526,13 +546,6 @@ void WayfirePanelApp::on_activate()
526546 new CssFromConfigFont (" panel/battery_font" , " .battery {" , " }" );
527547 new CssFromConfigFont (" panel/clock_font" , " .clock {" , " }" );
528548 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- }
536549}
537550
538551std::shared_ptr<WayfireIPC> WayfirePanelApp::get_ipc_server_instance ()
@@ -542,12 +555,7 @@ std::shared_ptr<WayfireIPC> WayfirePanelApp::get_ipc_server_instance()
542555
543556void WayfirePanelApp::handle_new_output (WayfireOutput *output)
544557{
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- }
558+ update_panels ();
551559}
552560
553561WayfirePanel*WayfirePanelApp::panel_for_wl_output (wl_output *output)
0 commit comments