diff --git a/src/display-console.cc b/src/display-console.cc index eb2eeb0df..0a0898091 100644 --- a/src/display-console.cc +++ b/src/display-console.cc @@ -50,10 +50,7 @@ void register_output(display_outputs_t &outputs) { } display_output_console::display_output_console(const std::string &name_) - : display_output_base(name_) { - // lowest priority, it's a fallback - priority = 0; -} + : display_output_base(name_) {} bool display_output_console::detect() { if ((out_to_stdout.get(*state) || out_to_stderr.get(*state)) diff --git a/src/display-file.cc b/src/display-file.cc index f1ff4c0f1..aed6a6c39 100644 --- a/src/display-file.cc +++ b/src/display-file.cc @@ -56,8 +56,6 @@ void register_output(display_outputs_t &outputs) { display_output_file::display_output_file(const std::string &name_) : display_output_base(name_) { - // lowest priority, it's a fallback - priority = 0; } bool display_output_file::detect() { diff --git a/src/display-http.cc b/src/display-http.cc index 78bfeee89..c93e8e6b5 100644 --- a/src/display-http.cc +++ b/src/display-http.cc @@ -127,7 +127,6 @@ std::string string_replace_all(std::string original, const std::string &oldpart, //} // namespace priv display_output_http::display_output_http() : display_output_base("http") { - priority = 0; httpd = NULL; } diff --git a/src/display-ncurses.cc b/src/display-ncurses.cc index 65fc3e5cc..05f854035 100644 --- a/src/display-ncurses.cc +++ b/src/display-ncurses.cc @@ -91,9 +91,7 @@ Colour from_ncurses(int nccolor) { } display_output_ncurses::display_output_ncurses() - : display_output_console("ncurses") { - priority = 1; -} + : display_output_console("ncurses") {} bool display_output_ncurses::detect() { if (out_to_ncurses.get(*state)) { diff --git a/src/display-output.cc b/src/display-output.cc index fafcf8c45..4c1da5b1f 100644 --- a/src/display-output.cc +++ b/src/display-output.cc @@ -80,22 +80,24 @@ std::vector current_display_outputs; bool initialize_display_outputs() { std::vector outputs; outputs.reserve(static_cast(output_t::OUTPUT_COUNT)); - register_output(outputs); + + // Order of registration is important! + // - Graphical outputs go before textual (e.g. X11 before NCurses). + // - Optional outputs go before non-optional (e.g. Wayland before X11). + // - Newer outputs go before older (e.g. NCurses before (hypothetical) Curses). + // - Fallbacks go last (in group) + register_output(outputs); + register_output(outputs); register_output(outputs); - register_output(outputs); register_output(outputs); - register_output(outputs); - register_output(outputs); + register_output(outputs); + register_output(outputs); // global fallback - always works for (auto out : outputs) { NORM_ERR("FOUND: %s", out->name.c_str()); } - // Sort display outputs by descending priority, to try graphical ones first. - sort(outputs.begin(), outputs.end(), &display_output_base::priority_compare); - int graphical_count = 0; for (auto output : outputs) { - if (output->priority < 0) continue; DBGP2("Testing display output '%s'... ", output->name.c_str()); if (output->detect()) { DBGP2("Detected display output '%s'... ", output->name.c_str()); diff --git a/src/display-output.hh b/src/display-output.hh index 52377c33f..55cc83b61 100644 --- a/src/display-output.hh +++ b/src/display-output.hh @@ -61,17 +61,11 @@ class display_output_base { const std::string name; bool is_active = false; bool is_graphical = false; - int priority = -1; explicit display_output_base(const std::string &name) : name(name){}; virtual ~display_output_base() {} - static bool priority_compare(const display_output_base *a, - const display_output_base *b) { - return a->priority > b->priority; - } - // check if available and enabled in settings virtual bool detect() { return false; } // connect to DISPLAY and other stuff diff --git a/src/display-wayland.cc b/src/display-wayland.cc index 54df0d74f..faa58c5ef 100644 --- a/src/display-wayland.cc +++ b/src/display-wayland.cc @@ -243,7 +243,6 @@ void register_output(display_outputs_t &outputs) { display_output_wayland::display_output_wayland() : display_output_base("wayland") { is_graphical = true; - priority = 3; } bool display_output_wayland::detect() { diff --git a/src/display-x11.cc b/src/display-x11.cc index 59e707131..1f0e74199 100644 --- a/src/display-x11.cc +++ b/src/display-x11.cc @@ -226,7 +226,6 @@ void register_output(display_outputs_t &outputs) { display_output_x11::display_output_x11() : display_output_base("x11") { is_graphical = true; - priority = 2; } bool display_output_x11::detect() {