mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(workspace): only show workspaces which are on same output as bar
This commit is contained in:
41
src/bar.cpp
41
src/bar.cpp
@ -16,8 +16,17 @@ waybar::Bar::Bar(Client &client, std::unique_ptr<struct wl_output *> &&p_output)
|
||||
.done = _handleDone,
|
||||
.scale = _handleScale,
|
||||
};
|
||||
|
||||
static const struct zxdg_output_v1_listener xdgOutputListener = {
|
||||
.logical_position = _handleLogicalPosition,
|
||||
.logical_size = _handleLogicalSize,
|
||||
.done = _handleDone,
|
||||
.name = _handleName,
|
||||
.description = _handleDescription,
|
||||
};
|
||||
wl_output_add_listener(*output, &outputListener, this);
|
||||
_xdgOutput =
|
||||
zxdg_output_manager_v1_get_xdg_output(client.xdg_output_manager, *output);
|
||||
zxdg_output_v1_add_listener(_xdgOutput, &xdgOutputListener, this);
|
||||
window.set_title("waybar");
|
||||
window.set_decorated(false);
|
||||
_setupConfig();
|
||||
@ -48,6 +57,36 @@ waybar::Bar::Bar(Client &client, std::unique_ptr<struct wl_output *> &&p_output)
|
||||
wl_surface_commit(surface);
|
||||
}
|
||||
|
||||
void waybar::Bar::_handleLogicalPosition(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1, int32_t x, int32_t y)
|
||||
{
|
||||
// Nothing here
|
||||
}
|
||||
|
||||
void waybar::Bar::_handleLogicalSize(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1, int32_t width, int32_t height)
|
||||
{
|
||||
// Nothing here
|
||||
}
|
||||
|
||||
void waybar::Bar::_handleDone(void *data, struct zxdg_output_v1 *zxdg_output_v1)
|
||||
{
|
||||
// Nothing here
|
||||
}
|
||||
|
||||
void waybar::Bar::_handleName(void *data, struct zxdg_output_v1 *xdg_output,
|
||||
const char *name)
|
||||
{
|
||||
auto o = reinterpret_cast<waybar::Bar *>(data);
|
||||
o->outputName = name;
|
||||
}
|
||||
|
||||
void waybar::Bar::_handleDescription(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1, const char *description)
|
||||
{
|
||||
// Nothing here
|
||||
}
|
||||
|
||||
void waybar::Bar::_handleGeometry(void *data, struct wl_output *wl_output,
|
||||
int32_t x, int32_t y, int32_t physical_width, int32_t physical_height,
|
||||
int32_t subpixel, const char *make, const char *model, int32_t transform)
|
||||
|
@ -50,13 +50,15 @@ void waybar::Client::_handle_global(void *data, struct wl_registry *registry,
|
||||
*output = (struct wl_output *)wl_registry_bind(registry, name,
|
||||
&wl_output_interface, version);
|
||||
o->bars.emplace_back(*o, std::move(output));
|
||||
} else if (!strcmp(interface, org_kde_kwin_idle_interface.name)) {
|
||||
o->idle_manager = (org_kde_kwin_idle *)wl_registry_bind(registry, name,
|
||||
&org_kde_kwin_idle_interface, version);
|
||||
} else if (!strcmp(interface, wl_seat_interface.name)) {
|
||||
o->seat = (struct wl_seat *)wl_registry_bind(registry, name,
|
||||
&wl_seat_interface, version);
|
||||
}
|
||||
} else if (!strcmp(interface, zxdg_output_manager_v1_interface.name)
|
||||
&& version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) {
|
||||
o->xdg_output_manager =
|
||||
(struct zxdg_output_manager_v1 *)wl_registry_bind(registry, name,
|
||||
&zxdg_output_manager_v1_interface, ZXDG_OUTPUT_V1_NAME_SINCE_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::Client::_handle_global_remove(void *data,
|
||||
|
@ -22,6 +22,7 @@ waybar::modules::Workspaces::Workspaces(Bar &bar)
|
||||
|
||||
auto waybar::modules::Workspaces::update() -> void
|
||||
{
|
||||
if (_bar.outputName.empty()) return;
|
||||
Json::Value workspaces = _getWorkspaces();
|
||||
bool needReorder = false;
|
||||
for (auto it = _buttons.begin(); it != _buttons.end(); ++it) {
|
||||
@ -34,7 +35,7 @@ auto waybar::modules::Workspaces::update() -> void
|
||||
}
|
||||
for (auto node : workspaces) {
|
||||
auto it = _buttons.find(node["num"].asInt());
|
||||
if (it == _buttons.end()) {
|
||||
if (it == _buttons.end() && _bar.outputName == node["output"].asString()) {
|
||||
_addWorkspace(node);
|
||||
needReorder = true;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user