Fix docs typos

Add removing buttons
Adjust handling multiple outputs.
pull/805/head
dmitry 2020-08-11 00:28:56 +03:00
parent 42b6c089f3
commit 22409d27c5
3 changed files with 25 additions and 4 deletions

View File

@ -85,6 +85,7 @@ class WorkspaceGroup {
auto handle_output_leave() -> void; auto handle_output_leave() -> void;
auto add_button(Gtk::Button &button) -> void; auto add_button(Gtk::Button &button) -> void;
auto remove_button(Gtk::Button &button) -> void;
auto handle_done() -> void; auto handle_done() -> void;
auto commit() -> void; auto commit() -> void;
auto sort_workspaces() -> void; auto sort_workspaces() -> void;

View File

@ -6,7 +6,7 @@ waybar - wlr workspaces module
# DESCRIPTION # DESCRIPTION
The *workspaces* module displays the currently used workspaces in waynland compositor. The *workspaces* module displays the currently used workspaces in wayland compositor.
# CONFIGURATION # CONFIGURATION
@ -35,7 +35,7 @@ Addressed by *wlr/workspaces*
# FORMAT REPLACEMENTS # FORMAT REPLACEMENTS
*{name}*: Number stripped from workspace value. *{name}*: Name of workspace assigned by compositor
*{icon}*: Icon, as defined in *format-icons*. *{icon}*: Icon, as defined in *format-icons*.
@ -43,7 +43,7 @@ Addressed by *wlr/workspaces*
Additional to workspace name matching, the following *format-icons* can be set. Additional to workspace name matching, the following *format-icons* can be set.
- *default*: Will be shown, when no string matches is found. - *default*: Will be shown, when no string match is found.
- *focused*: Will be shown, when workspace is focused - *focused*: Will be shown, when workspace is focused
# EXAMPLES # EXAMPLES
@ -65,5 +65,6 @@ Additional to workspace name matching, the following *format-icons* can be set.
# Style # Style
- *#workspaces*
- *#workspaces button* - *#workspaces button*
- *#workspaces button.focused* - *#workspaces button.focused*

View File

@ -1,5 +1,6 @@
#include "modules/wlr/workspace_manager.hpp" #include "modules/wlr/workspace_manager.hpp"
#include <gdk/gdkwayland.h>
#include <gtkmm.h> #include <gtkmm.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
@ -77,6 +78,7 @@ WorkspaceManager::~WorkspaceManager() {
zwlr_workspace_manager_v1_destroy(workspace_manager_); zwlr_workspace_manager_v1_destroy(workspace_manager_);
workspace_manager_ = nullptr; workspace_manager_ = nullptr;
} }
auto WorkspaceManager::remove_workspace_group(uint32_t id) -> void { auto WorkspaceManager::remove_workspace_group(uint32_t id) -> void {
auto it = std::find_if(groups_.begin(), auto it = std::find_if(groups_.begin(),
groups_.end(), groups_.end(),
@ -111,6 +113,7 @@ WorkspaceGroup::WorkspaceGroup(const Bar &bar, Gtk::Box &box, const Json::Value
sort_by_coordinates = config_sort_by_coordinates.asBool(); sort_by_coordinates = config_sort_by_coordinates.asBool();
} }
} }
auto WorkspaceGroup::add_button(Gtk::Button &button) -> void { auto WorkspaceGroup::add_button(Gtk::Button &button) -> void {
box_.pack_start(button, false, false); box_.pack_start(button, false, false);
} }
@ -138,15 +141,25 @@ auto WorkspaceGroup::handle_remove() -> void {
auto WorkspaceGroup::handle_output_enter(wl_output *output) -> void { auto WorkspaceGroup::handle_output_enter(wl_output *output) -> void {
spdlog::debug("Output {} assigned to {} group", (void *)output, id_); spdlog::debug("Output {} assigned to {} group", (void *)output, id_);
output_ = output;
if (output != gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj())) {
return;
}
for (auto &workspace : workspaces_) { for (auto &workspace : workspaces_) {
workspace->show(); workspace->show();
} }
output_ = output;
} }
auto WorkspaceGroup::handle_output_leave() -> void { auto WorkspaceGroup::handle_output_leave() -> void {
spdlog::debug("Output {} remove from {} group", (void *)output_, id_); spdlog::debug("Output {} remove from {} group", (void *)output_, id_);
output_ = nullptr; output_ = nullptr;
if (output_ != gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj())) {
return;
}
for (auto &workspace : workspaces_) { for (auto &workspace : workspaces_) {
workspace->hide(); workspace->hide();
} }
@ -176,6 +189,7 @@ auto WorkspaceGroup::handle_done() -> void {
workspace->handle_done(); workspace->handle_done();
} }
} }
auto WorkspaceGroup::commit() -> void { workspace_manager_.commit(); } auto WorkspaceGroup::commit() -> void { workspace_manager_.commit(); }
auto WorkspaceGroup::sort_workspaces() -> void { auto WorkspaceGroup::sort_workspaces() -> void {
@ -207,6 +221,10 @@ auto WorkspaceGroup::sort_workspaces() -> void {
} }
} }
auto WorkspaceGroup::remove_button(Gtk::Button &button) -> void {
box_.remove(button);
}
Workspace::Workspace(const Bar &bar, const Json::Value &config, WorkspaceGroup &workspace_group, Workspace::Workspace(const Bar &bar, const Json::Value &config, WorkspaceGroup &workspace_group,
zwlr_workspace_handle_v1 *workspace, uint32_t id) zwlr_workspace_handle_v1 *workspace, uint32_t id)
: bar_(bar), : bar_(bar),
@ -244,6 +262,7 @@ Workspace::Workspace(const Bar &bar, const Json::Value &config, WorkspaceGroup &
} }
Workspace::~Workspace() { Workspace::~Workspace() {
workspace_group_.remove_button(button_);
if (!workspace_handle_) { if (!workspace_handle_) {
return; return;
} }