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
27 changes: 27 additions & 0 deletions include/modules/wlr/taskbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "AModule.hpp"
#include "bar.hpp"
#include "client.hpp"
#include "ext-workspace-v1-client-protocol.h"
#include "giomm/desktopappinfo.h"
#include "util/icon_loader.hpp"
#include "util/json.hpp"
Expand Down Expand Up @@ -80,6 +81,7 @@ class Task {
std::string title_;
std::string app_id_;
uint32_t state_ = 0;
struct ext_workspace_handle_v1* workspace_ = nullptr;

int32_t drag_start_x;
int32_t drag_start_y;
Expand All @@ -102,6 +104,9 @@ class Task {
bool minimized() const { return state_ & MINIMIZED; }
bool active() const { return state_ & ACTIVE; }
bool fullscreen() const { return state_ & FULLSCREEN; }
bool visible() const { return button_visible_; }
struct ext_workspace_handle_v1* workspace() const { return workspace_; }
void set_workspace(struct ext_workspace_handle_v1* workspace) { workspace_ = workspace; }

public:
/* Callbacks for the wlr protocol */
Expand Down Expand Up @@ -142,6 +147,12 @@ using TaskPtr = std::unique_ptr<Task>;

class Taskbar : public waybar::AModule {
public:
struct WorkspaceState {
Taskbar* taskbar;
struct ext_workspace_handle_v1* handle;
uint32_t state = 0;
};

Taskbar(const std::string&, const waybar::Bar&, const Json::Value&);
~Taskbar();
void update();
Expand All @@ -156,29 +167,45 @@ class Taskbar : public waybar::AModule {
std::map<std::string, std::string> app_ids_replace_map_;

struct zwlr_foreign_toplevel_manager_v1* manager_;
struct ext_workspace_manager_v1* workspace_manager_;
struct wl_seat* seat_;
std::vector<struct ext_workspace_group_handle_v1*> workspace_groups_;
std::vector<std::unique_ptr<WorkspaceState>> workspaces_;
struct ext_workspace_handle_v1* current_workspace_ = nullptr;

public:
/* Callbacks for global registration */
void register_manager(struct wl_registry*, uint32_t name, uint32_t version);
void register_workspace_manager(struct wl_registry*, uint32_t name, uint32_t version);
void register_seat(struct wl_registry*, uint32_t name, uint32_t version);

/* Callbacks for the wlr protocol */
void handle_toplevel_create(struct zwlr_foreign_toplevel_handle_v1*);
void handle_finished();
void handle_workspace_group_create(struct ext_workspace_group_handle_v1*);
void handle_workspace_group_removed(struct ext_workspace_group_handle_v1*);
void handle_workspace_create(struct ext_workspace_handle_v1*);
void handle_workspace_done();
void handle_workspace_finished();
void handle_workspace_removed(struct ext_workspace_handle_v1*);

public:
void add_button(Gtk::Button&);
void move_button(Gtk::Button&, int);
void remove_button(Gtk::Button&);
void remove_task(uint32_t);
void assign_current_workspace(Task&);
void update_bar_css_classes();

bool show_output(struct wl_output*) const;
bool all_outputs() const;

const IconLoader& icon_loader() const;
const std::unordered_set<std::string>& ignore_list() const;
const std::map<std::string, std::string>& app_ids_replace_map() const;

private:
void set_bar_css_class(const std::string&, bool);
};

} /* namespace waybar::modules::wlr */
45 changes: 45 additions & 0 deletions man/waybar-wlr-taskbar.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ Addressed by *wlr/taskbar*
default: false ++
If set to false applications on the waybar's current output will be shown. Otherwise, all applications are shown.

*bar-css-states*: ++
typeof: bool ++
default: false ++
If set to true, application state is exposed as CSS classes on the Waybar
window. Maximized and fullscreen state is aggregated across applications
known to belong to the active workspace. See *Bar state style* below.

*format*: ++
typeof: string ++
default: {icon} ++
Expand Down Expand Up @@ -52,6 +59,12 @@ Addressed by *wlr/taskbar*
default: false ++
If set to true, always reorder the tasks in the taskbar so that the currently active one is first. Otherwise don't reorder.

*active-only*: ++
typeof: bool ++
default: false ++
If set to true, only the currently active application button is shown.
Other applications remain tracked and reappear when activated.

*sort-by-app-id*: ++
typeof: bool ++
default: false ++
Expand Down Expand Up @@ -156,3 +169,35 @@ Invalid expressions (e.g., mismatched parentheses) are skipped.
- *#taskbar button.minimized*
- *#taskbar button.active*
- *#taskbar button.fullscreen*

# Bar state style

When *bar-css-states* is enabled, the following classes are added to
*window#waybar*:

- *window#waybar.toplevel-active*
- *window#waybar.toplevel-maximized*
- *window#waybar.toplevel-minimized*
- *window#waybar.toplevel-fullscreen*

The active, minimized classes describe the active application. The maximized
and fullscreen classes are set if any non-minimized application known to belong
to the active workspace has that state.

Workspace membership is learned when an application is activated and requires
the compositor to support *ext-workspace-v1*. Before an application has been
activated during the current Waybar session, its workspace may be unknown. On
compositors without *ext-workspace-v1*, these classes fall back to the active
application's state.

For example:

```
window#waybar {
background-color: rgba(0, 0, 0, 0.5);
}

window#waybar.toplevel-maximized {
background-color: rgba(0, 0, 0, 1);
}
```
Loading