Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out_to_wayland giving nothing #2103

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/display-console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ void register_output<output_t::CONSOLE>(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))
Expand Down
2 changes: 0 additions & 2 deletions src/display-file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ void register_output<output_t::FILE>(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() {
Expand Down
1 change: 0 additions & 1 deletion src/display-http.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 1 addition & 3 deletions src/display-ncurses.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
20 changes: 11 additions & 9 deletions src/display-output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,24 @@ std::vector<conky::display_output_base *> current_display_outputs;
bool initialize_display_outputs() {
std::vector<display_output_base *> outputs;
outputs.reserve(static_cast<size_t>(output_t::OUTPUT_COUNT));
register_output<output_t::CONSOLE>(outputs);
register_output<output_t::NCURSES>(outputs);
register_output<output_t::FILE>(outputs);
register_output<output_t::HTTP>(outputs);
register_output<output_t::X11>(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<output_t::WAYLAND>(outputs);
register_output<output_t::X11>(outputs);
register_output<output_t::HTTP>(outputs);
register_output<output_t::FILE>(outputs);
register_output<output_t::NCURSES>(outputs);
register_output<output_t::CONSOLE>(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());
Expand Down
6 changes: 0 additions & 6 deletions src/display-output.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/display-wayland.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ void register_output<output_t::WAYLAND>(display_outputs_t &outputs) {
display_output_wayland::display_output_wayland()
: display_output_base("wayland") {
is_graphical = true;
priority = 2;
}

bool display_output_wayland::detect() {
Expand Down
1 change: 0 additions & 1 deletion src/display-x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ void register_output<output_t::X11>(display_outputs_t &outputs) {

display_output_x11::display_output_x11() : display_output_base("x11") {
is_graphical = true;
priority = 2;
}

bool display_output_x11::detect() {
Expand Down
Loading