Skip to content
Open
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
6 changes: 6 additions & 0 deletions man/waybar.5.scd.in
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ The visual display elements for waybar use a CSS stylesheet. Waybar supports *st
default: *true* ++
Option to request an exclusive zone from the compositor. Disable this to allow drawing application windows underneath or on top of the bar.

*exclusive_output* ++
typeof: bool ++
default: *false* ++
Displays Waybar on the first monitor in a monitor list if multiple monitors are connected.


*fixed-center* ++
typeof: bool ++
default: *true*
Expand Down
39 changes: 32 additions & 7 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <iostream>
#include <utility>

#include "gtkmm/icontheme.h"
#include "ext-idle-notify-v1-client-protocol.h"
#include "gtkmm/icontheme.h"
#include "idle-inhibit-unstable-v1-client-protocol.h"
#include "util/clara.hpp"
#include "util/format.hpp"
Expand Down Expand Up @@ -47,7 +47,7 @@ void waybar::Client::handleGlobal(void* data, struct wl_registry* registry, uint
} else if (strcmp(interface, ext_idle_notifier_v1_interface.name) == 0) {
// Bind version 2 if available (for get_input_idle_notification), otherwise version 1
auto bind_version = std::min(version, 2u);
client->idle_notifier = static_cast<struct ext_idle_notifier_v1 *>(
client->idle_notifier = static_cast<struct ext_idle_notifier_v1*>(
wl_registry_bind(registry, name, &ext_idle_notifier_v1_interface, bind_version));
spdlog::debug("Bound ext-idle-notifier-v1 at version {}", bind_version);
#ifdef HAVE_BAR_BLUR
Expand Down Expand Up @@ -122,16 +122,23 @@ void waybar::Client::handleOutputDone(void* data, struct zxdg_output_v1* /*xdg_o
*/
if (output.xdg_output) {
output.xdg_output.reset();

const auto& config = client->config.getConfig();
if (client->gdk_display->get_n_monitors() > 1 && config["exclusive_output"].asBool()) {
if (config["output"].isArray() && config["output"][0].asString() != output.name) {
return;
}
}

spdlog::debug("Output detection done: {} ({})", output.name, output.identifier);

client->pending_outputs_.push_back(&output);

if (!client->bars_scheduled_) {
client->bars_scheduled_ = true;

Glib::signal_idle().connect_once([client]() {
client->createBarsBatch();
}, Glib::PRIORITY_HIGH_IDLE);
Glib::signal_idle().connect_once([client]() { client->createBarsBatch(); },
Glib::PRIORITY_HIGH_IDLE);
}
}
} catch (const std::exception& e) {
Expand All @@ -140,7 +147,21 @@ void waybar::Client::handleOutputDone(void* data, struct zxdg_output_v1* /*xdg_o
}

void waybar::Client::createBarsBatch() {
pending_outputs_.remove_if([this](auto* output) { return std::none_of(outputs_.begin(), outputs_.end(), [&output](const auto& o) { return &o == output; }); });
auto& conf = config.getConfig();
if (gdk_display->get_n_monitors() > 1 && conf["exclusive_output"].asBool()) {
for (auto it = bars.begin(); it != bars.end();) {
if (conf["output"].isArray() && conf["output"][0].asString() != (*it)->output->name) {
(*it)->window.hide();
gtk_app->remove_window((*it)->window);
it = bars.erase(it);
}
}
}

pending_outputs_.remove_if([this](auto* output) {
return std::none_of(outputs_.begin(), outputs_.end(),
[&output](const auto& o) { return &o == output; });
});
for (auto* output : pending_outputs_) {
try {
auto configs = getOutputConfigs(*output);
Expand Down Expand Up @@ -215,6 +236,9 @@ void waybar::Client::handleDeferredMonitorRemoval(Glib::RefPtr<Gdk::Monitor> mon
}
}
outputs_.remove_if([&monitor](const auto& output) { return output.monitor == monitor; });
if (config.getConfig()["exclusive_output"].asBool()) {
bindInterfaces();
}
}

const std::string waybar::Client::getStyle(const std::string& style,
Expand Down Expand Up @@ -384,7 +408,8 @@ int waybar::Client::main(int argc, char* argv[]) {
}
m_cssFile = getStyle(style_opt);
setupCss(m_cssFile);
m_cssReloadHelper = std::make_unique<CssReloadHelper>(m_cssFile, [&](const std::string& css_file) { setupCss(css_file); });
m_cssReloadHelper = std::make_unique<CssReloadHelper>(
m_cssFile, [&](const std::string& css_file) { setupCss(css_file); });
if (portal) {
portal->signal_appearance_changed().connect([&](waybar::Appearance appearance) {
auto css_file = getStyle(style_opt, appearance);
Expand Down