Update names

This commit is contained in:
dmitry 2021-11-21 15:01:25 +03:00
parent 15761ef802
commit ffeecf626c
6 changed files with 125 additions and 89 deletions

View File

@ -11,7 +11,7 @@
#include "AModule.hpp" #include "AModule.hpp"
#include "bar.hpp" #include "bar.hpp"
#include "wlr-workspace-unstable-v1-client-protocol.h" #include "ext-workspace-unstable-v1-client-protocol.h"
namespace waybar::modules::wlr { namespace waybar::modules::wlr {
@ -21,7 +21,7 @@ class WorkspaceGroup;
class Workspace { class Workspace {
public: public:
Workspace(const waybar::Bar &bar, const Json::Value &config, WorkspaceGroup &workspace_group, Workspace(const waybar::Bar &bar, const Json::Value &config, WorkspaceGroup &workspace_group,
zwlr_workspace_handle_v1 *workspace, uint32_t id); zext_workspace_handle_v1 *workspace, uint32_t id);
~Workspace(); ~Workspace();
auto update() -> void; auto update() -> void;
@ -51,7 +51,7 @@ class Workspace {
WorkspaceGroup & workspace_group_; WorkspaceGroup & workspace_group_;
// wlr stuff // wlr stuff
zwlr_workspace_handle_v1 *workspace_handle_; zext_workspace_handle_v1 *workspace_handle_;
uint32_t state_ = 0; uint32_t state_ = 0;
uint32_t id_; uint32_t id_;
@ -69,7 +69,7 @@ class Workspace {
class WorkspaceGroup { class WorkspaceGroup {
public: public:
WorkspaceGroup(const waybar::Bar &bar, Gtk::Box &box, const Json::Value &config, WorkspaceGroup(const waybar::Bar &bar, Gtk::Box &box, const Json::Value &config,
WorkspaceManager &manager, zwlr_workspace_group_handle_v1 *workspace_group_handle, WorkspaceManager &manager, zext_workspace_group_handle_v1 *workspace_group_handle,
uint32_t id); uint32_t id);
~WorkspaceGroup(); ~WorkspaceGroup();
auto update() -> void; auto update() -> void;
@ -79,7 +79,7 @@ class WorkspaceGroup {
auto remove_workspace(uint32_t id_) -> void; auto remove_workspace(uint32_t id_) -> void;
// wlr stuff // wlr stuff
auto handle_workspace_create(zwlr_workspace_handle_v1 *workspace_handle) -> void; auto handle_workspace_create(zext_workspace_handle_v1 *workspace_handle) -> void;
auto handle_remove() -> void; auto handle_remove() -> void;
auto handle_output_enter(wl_output *output) -> void; auto handle_output_enter(wl_output *output) -> void;
auto handle_output_leave() -> void; auto handle_output_leave() -> void;
@ -98,7 +98,7 @@ class WorkspaceGroup {
WorkspaceManager & workspace_manager_; WorkspaceManager & workspace_manager_;
// wlr stuff // wlr stuff
zwlr_workspace_group_handle_v1 *workspace_group_handle_; zext_workspace_group_handle_v1 *workspace_group_handle_;
wl_output * output_ = nullptr; wl_output * output_ = nullptr;
uint32_t id_; uint32_t id_;
@ -117,7 +117,7 @@ class WorkspaceManager : public AModule {
// wlr stuff // wlr stuff
auto register_manager(wl_registry *registry, uint32_t name, uint32_t version) -> void; auto register_manager(wl_registry *registry, uint32_t name, uint32_t version) -> void;
auto handle_workspace_group_create(zwlr_workspace_group_handle_v1 *workspace_group_handle) auto handle_workspace_group_create(zext_workspace_group_handle_v1 *workspace_group_handle)
-> void; -> void;
auto handle_done() -> void; auto handle_done() -> void;
auto handle_finished() -> void; auto handle_finished() -> void;
@ -130,7 +130,7 @@ class WorkspaceManager : public AModule {
std::vector<std::unique_ptr<WorkspaceGroup>> groups_; std::vector<std::unique_ptr<WorkspaceGroup>> groups_;
// wlr stuff // wlr stuff
zwlr_workspace_manager_v1 *workspace_manager_ = nullptr; zext_workspace_manager_v1 *workspace_manager_ = nullptr;
static uint32_t group_global_id; static uint32_t group_global_id;
}; };

View File

@ -1,8 +1,8 @@
#include "wlr-workspace-unstable-v1-client-protocol.h" #include "ext-workspace-unstable-v1-client-protocol.h"
namespace waybar::modules::wlr { namespace waybar::modules::wlr {
void add_registry_listener(void *data); void add_registry_listener(void *data);
void add_workspace_listener(zwlr_workspace_handle_v1 *workspace_handle, void *data); void add_workspace_listener(zext_workspace_handle_v1 *workspace_handle, void *data);
void add_workspace_group_listener(zwlr_workspace_group_handle_v1 *workspace_group_handle, void *data); void add_workspace_group_listener(zext_workspace_group_handle_v1 *workspace_group_handle, void *data);
zwlr_workspace_manager_v1* workspace_manager_bind(wl_registry *registry, uint32_t name, uint32_t version, void *data); zext_workspace_manager_v1* workspace_manager_bind(wl_registry *registry, uint32_t name, uint32_t version, void *data);
} }

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<protocol name="wlr_workspace_unstable_v1"> <protocol name="ext_workspace_unstable_v1">
<copyright> <copyright>
Copyright © 2019 Christopher Billington Copyright © 2019 Christopher Billington
Copyright © 2020 Ilia Bozhinov Copyright © 2020 Ilia Bozhinov
@ -26,7 +26,7 @@
THIS SOFTWARE. THIS SOFTWARE.
</copyright> </copyright>
<interface name="zwlr_workspace_manager_v1" version="1"> <interface name="zext_workspace_manager_v1" version="1">
<description summary="list and control workspaces"> <description summary="list and control workspaces">
Workspaces, also called virtual desktops, are groups of surfaces. A Workspaces, also called virtual desktops, are groups of surfaces. A
compositor with a concept of workspaces may only show some such groups of compositor with a concept of workspaces may only show some such groups of
@ -45,7 +45,7 @@
docks by providing them with a list of workspaces and their properties, docks by providing them with a list of workspaces and their properties,
and allowing them to activate and deactivate workspaces. and allowing them to activate and deactivate workspaces.
After a client binds the zwlr_workspace_manager_v1, each workspace will be After a client binds the zext_workspace_manager_v1, each workspace will be
sent via the workspace event. sent via the workspace event.
</description> </description>
@ -55,9 +55,9 @@
All initial details of the workspace group (workspaces, outputs) will be All initial details of the workspace group (workspaces, outputs) will be
sent immediately after this event via the corresponding events in sent immediately after this event via the corresponding events in
zwlr_workspace_group_handle_v1. zext_workspace_group_handle_v1.
</description> </description>
<arg name="workspace_group" type="new_id" interface="zwlr_workspace_group_handle_v1"/> <arg name="workspace_group" type="new_id" interface="zext_workspace_group_handle_v1"/>
</event> </event>
<request name="commit"> <request name="commit">
@ -68,21 +68,21 @@
This allows changes to the workspace properties to be seen as atomic, This allows changes to the workspace properties to be seen as atomic,
even if they happen via multiple events, and even if they involve even if they happen via multiple events, and even if they involve
multiple zwlr_workspace_handle_v1 objects, for example, deactivating one multiple zext_workspace_handle_v1 objects, for example, deactivating one
workspace and activating another. workspace and activating another.
</description> </description>
</request> </request>
<event name="done"> <event name="done">
<description summary="all information about the workspace groups has been sent"> <description summary="all information about the workspace groups has been sent">
This event is sent after all changes in all workspace groups have been This event is sent after all changes in all workspace groups have been
sent. sent.
This allows changes to one or more zwlr_workspace_group_handle_v1 This allows changes to one or more zext_workspace_group_handle_v1
properties to be seen as atomic, even if they happen via multiple properties to be seen as atomic, even if they happen via multiple
events. In particular, an output moving from one workspace group to events. In particular, an output moving from one workspace group to
another sends an output_enter event and an output_leave event to the two another sends an output_enter event and an output_leave event to the two
zwlr_workspace_group_handle_v1 objects in question. The compositor sends zext_workspace_group_handle_v1 objects in question. The compositor sends
the done event only after updating the output information in both the done event only after updating the output information in both
workspace groups. workspace groups.
</description> </description>
@ -91,7 +91,7 @@
<event name="finished"> <event name="finished">
<description summary="the compositor has finished with the workspace_manager"> <description summary="the compositor has finished with the workspace_manager">
This event indicates that the compositor is done sending events to the This event indicates that the compositor is done sending events to the
zwlr_workspace_manager_v1. The server will destroy the object zext_workspace_manager_v1. The server will destroy the object
immediately after sending this request, so it will become invalid and immediately after sending this request, so it will become invalid and
the client should free any resources associated with it. the client should free any resources associated with it.
</description> </description>
@ -108,14 +108,19 @@
</request> </request>
</interface> </interface>
<interface name="zwlr_workspace_group_handle_v1" version="1"> <interface name="zext_workspace_group_handle_v1" version="1">
<description summary="a workspace group assigned to a set of outputs"> <description summary="a workspace group assigned to a set of outputs">
A zwlr_workspace_group_handle_v1 object represents a a workspace group A zext_workspace_group_handle_v1 object represents a a workspace group
that is assigned a set of outputs and contains a number of workspaces. that is assigned a set of outputs and contains a number of workspaces.
The set of outputs assigned to the workspace group is conveyed to the client via The set of outputs assigned to the workspace group is conveyed to the client via
output_enter and output_leave events, and its workspaces are conveyed with output_enter and output_leave events, and its workspaces are conveyed with
workspace events. workspace events.
For example, a compositor which has a set of workspaces for each output may
advertise a workspace group (and its workspaces) per output, whereas a compositor
where a workspace spans all outputs may advertise a single workspace group for all
outputs.
</description> </description>
<event name="output_enter"> <event name="output_enter">
@ -140,26 +145,36 @@
All initial details of the workspace (name, coordinates, state) will All initial details of the workspace (name, coordinates, state) will
be sent immediately after this event via the corresponding events in be sent immediately after this event via the corresponding events in
zwlr_workspace_handle_v1. zext_workspace_handle_v1.
</description> </description>
<arg name="workspace" type="new_id" interface="zwlr_workspace_handle_v1"/> <arg name="workspace" type="new_id" interface="zext_workspace_handle_v1"/>
</event> </event>
<event name="remove"> <event name="remove">
<description summary="this workspace group has been destroyed"> <description summary="this workspace group has been destroyed">
This event means the zwlr_workspace_group_handle_v1 has been destroyed. This event means the zext_workspace_group_handle_v1 has been destroyed.
It is guaranteed there won't be any more events for this It is guaranteed there won't be any more events for this
zwlr_workspace_group_handle_v1. The zwlr_workspace_group_handle_v1 becomes zext_workspace_group_handle_v1. The zext_workspace_group_handle_v1 becomes
inert so any requests will be ignored except the destroy request. inert so any requests will be ignored except the destroy request.
The compositor must remove all workspaces belonging to a workspace group The compositor must remove all workspaces belonging to a workspace group
before removing the workspace group. before removing the workspace group.
</description> </description>
</event> </event>
<request name="create_workspace">
<description summary="create a new workspace">
Request that the compositor create a new workspace with the given name.
There is no guarantee that the compositor will create a new workspace,
or that the created workspace will have the provided name.
</description>
<arg name="workspace" type="string"/>
</request>
<request name="destroy" type="destructor"> <request name="destroy" type="destructor">
<description summary="destroy the zwlr_workspace_handle_v1 object"> <description summary="destroy the zext_workspace_handle_v1 object">
Destroys the zwlr_workspace_handle_v1 object. Destroys the zext_workspace_handle_v1 object.
This request should be called either when the client does not want to This request should be called either when the client does not want to
use the workspace object any more or after the remove event to finalize use the workspace object any more or after the remove event to finalize
@ -168,9 +183,9 @@
</request> </request>
</interface> </interface>
<interface name="zwlr_workspace_handle_v1" version="1"> <interface name="zext_workspace_handle_v1" version="1">
<description summary="a workspace handing a group of surfaces"> <description summary="a workspace handing a group of surfaces">
A zwlr_workspace_handle_v1 object represents a a workspace that handles a A zext_workspace_handle_v1 object represents a a workspace that handles a
group of surfaces. group of surfaces.
Each workspace has a name, conveyed to the client with the name event; a Each workspace has a name, conveyed to the client with the name event; a
@ -178,11 +193,16 @@
optionally a set of coordinates, conveyed to the client with the optionally a set of coordinates, conveyed to the client with the
coordinates event. The client may request that the compositor activate or coordinates event. The client may request that the compositor activate or
deactivate the workspace. deactivate the workspace.
Each workspace can belong to only a single workspace group.
Depepending on the compositor policy, there might be workspaces with
the same name in different workspace groups, but these workspaces are still
separate (e.g. one of them might be active while the other is not).
</description> </description>
<event name="name"> <event name="name">
<description summary="workspace name changed"> <description summary="workspace name changed">
This event is emitted immediately after the zwlr_workspace_handle_v1 is This event is emitted immediately after the zext_workspace_handle_v1 is
created and whenever the name of the workspace changes. created and whenever the name of the workspace changes.
</description> </description>
<arg name="name" type="string"/> <arg name="name" type="string"/>
@ -192,13 +212,13 @@
<description summary="workspace coordinates changed"> <description summary="workspace coordinates changed">
This event is used to organize workspaces into an N-dimensional grid This event is used to organize workspaces into an N-dimensional grid
within a workspace group, and if supported, is emitted immediately after within a workspace group, and if supported, is emitted immediately after
the zwlr_workspace_handle_v1 is created and whenever the coordinates of the zext_workspace_handle_v1 is created and whenever the coordinates of
the workspace change. Compositors may not send this event if they do not the workspace change. Compositors may not send this event if they do not
conceptually arrange workspaces in this way. If compositors simply conceptually arrange workspaces in this way. If compositors simply
number workspaces, without any geometric interpretation, they may send number workspaces, without any geometric interpretation, they may send
1D coordinates, which clients should not interpret as implying any 1D coordinates, which clients should not interpret as implying any
geometry. Sending an empty array means that the compositor no longer geometry. Sending an empty array means that the compositor no longer
orders the workspace geometrically. orders the workspace geometrically.
Coordinates have an arbitrary number of dimensions N with an uint32 Coordinates have an arbitrary number of dimensions N with an uint32
position along each dimension. By convention if N > 1, the first position along each dimension. By convention if N > 1, the first
@ -214,7 +234,7 @@
<event name="state"> <event name="state">
<description summary="the state of the workspace changed"> <description summary="the state of the workspace changed">
This event is emitted immediately after the zwlr_workspace_handle_v1 is This event is emitted immediately after the zext_workspace_handle_v1 is
created and each time the workspace state changes, either because of a created and each time the workspace state changes, either because of a
compositor action or because of a request in this protocol. compositor action or because of a request in this protocol.
</description> </description>
@ -227,20 +247,28 @@
</description> </description>
<entry name="active" value="0" summary="the workspace is active"/> <entry name="active" value="0" summary="the workspace is active"/>
<entry name="urgent" value="1" summary="the workspace requests attention"/>
<entry name="hidden" value="2">
<description summary="the workspace is not visible">
The workspace is not visible in its workspace group, and clients
attempting to visualize the compositor workspace state should not
display such workspaces.
</description>
</entry>
</enum> </enum>
<event name="remove"> <event name="remove">
<description summary="this workspace has been destroyed"> <description summary="this workspace has been destroyed">
This event means the zwlr_workspace_handle_v1 has been destroyed. It is This event means the zext_workspace_handle_v1 has been destroyed. It is
guaranteed there won't be any more events for this guaranteed there won't be any more events for this
zwlr_workspace_handle_v1. The zwlr_workspace_handle_v1 becomes inert so zext_workspace_handle_v1. The zext_workspace_handle_v1 becomes inert so
any requests will be ignored except the destroy request. any requests will be ignored except the destroy request.
</description> </description>
</event> </event>
<request name="destroy" type="destructor"> <request name="destroy" type="destructor">
<description summary="destroy the zwlr_workspace_handle_v1 object"> <description summary="destroy the zext_workspace_handle_v1 object">
Destroys the zwlr_workspace_handle_v1 object. Destroys the zext_workspace_handle_v1 object.
This request should be called either when the client does not want to This request should be called either when the client does not want to
use the workspace object any more or after the remove event to finalize use the workspace object any more or after the remove event to finalize
@ -266,5 +294,13 @@
There is no guarantee the workspace will be actually deactivated. There is no guarantee the workspace will be actually deactivated.
</description> </description>
</request> </request>
<request name="remove">
<description summary="remove the workspace">
Request that this workspace be removed.
There is no guarantee the workspace will be actually removed.
</description>
</request>
</interface> </interface>
</protocol> </protocol>

View File

@ -27,7 +27,7 @@ client_protocols = [
[wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'], [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'],
['wlr-layer-shell-unstable-v1.xml'], ['wlr-layer-shell-unstable-v1.xml'],
['wlr-foreign-toplevel-management-unstable-v1.xml'], ['wlr-foreign-toplevel-management-unstable-v1.xml'],
['wlr-workspace-unstable-v1.xml'], ['ext-workspace-unstable-v1.xml'],
['river-status-unstable-v1.xml'], ['river-status-unstable-v1.xml'],
] ]

View File

@ -44,7 +44,7 @@ auto WorkspaceManager::register_manager(wl_registry *registry, uint32_t name, ui
} }
auto WorkspaceManager::handle_workspace_group_create( auto WorkspaceManager::handle_workspace_group_create(
zwlr_workspace_group_handle_v1 *workspace_group_handle) -> void { zext_workspace_group_handle_v1 *workspace_group_handle) -> void {
auto new_id = ++group_global_id; auto new_id = ++group_global_id;
groups_.push_back( groups_.push_back(
std::make_unique<WorkspaceGroup>(bar_, box_, config_, *this, workspace_group_handle, new_id)); std::make_unique<WorkspaceGroup>(bar_, box_, config_, *this, workspace_group_handle, new_id));
@ -52,7 +52,7 @@ auto WorkspaceManager::handle_workspace_group_create(
} }
auto WorkspaceManager::handle_finished() -> void { auto WorkspaceManager::handle_finished() -> void {
zwlr_workspace_manager_v1_destroy(workspace_manager_); zext_workspace_manager_v1_destroy(workspace_manager_);
workspace_manager_ = nullptr; workspace_manager_ = nullptr;
} }
@ -75,7 +75,7 @@ WorkspaceManager::~WorkspaceManager() {
return; return;
} }
zwlr_workspace_manager_v1_destroy(workspace_manager_); zext_workspace_manager_v1_destroy(workspace_manager_);
workspace_manager_ = nullptr; workspace_manager_ = nullptr;
} }
@ -91,11 +91,11 @@ auto WorkspaceManager::remove_workspace_group(uint32_t id) -> void {
groups_.erase(it); groups_.erase(it);
} }
auto WorkspaceManager::commit() -> void { zwlr_workspace_manager_v1_commit(workspace_manager_); } auto WorkspaceManager::commit() -> void { zext_workspace_manager_v1_commit(workspace_manager_); }
WorkspaceGroup::WorkspaceGroup(const Bar &bar, Gtk::Box &box, const Json::Value &config, WorkspaceGroup::WorkspaceGroup(const Bar &bar, Gtk::Box &box, const Json::Value &config,
WorkspaceManager & manager, WorkspaceManager & manager,
zwlr_workspace_group_handle_v1 *workspace_group_handle, uint32_t id) zext_workspace_group_handle_v1 *workspace_group_handle, uint32_t id)
: bar_(bar), : bar_(bar),
box_(box), box_(box),
config_(config), config_(config),
@ -123,18 +123,18 @@ WorkspaceGroup::~WorkspaceGroup() {
return; return;
} }
zwlr_workspace_group_handle_v1_destroy(workspace_group_handle_); zext_workspace_group_handle_v1_destroy(workspace_group_handle_);
workspace_group_handle_ = nullptr; workspace_group_handle_ = nullptr;
} }
auto WorkspaceGroup::handle_workspace_create(zwlr_workspace_handle_v1 *workspace) -> void { auto WorkspaceGroup::handle_workspace_create(zext_workspace_handle_v1 *workspace) -> void {
auto new_id = ++workspace_global_id; auto new_id = ++workspace_global_id;
workspaces_.push_back(std::make_unique<Workspace>(bar_, config_, *this, workspace, new_id)); workspaces_.push_back(std::make_unique<Workspace>(bar_, config_, *this, workspace, new_id));
spdlog::debug("Workspace {} created", new_id); spdlog::debug("Workspace {} created", new_id);
} }
auto WorkspaceGroup::handle_remove() -> void { auto WorkspaceGroup::handle_remove() -> void {
zwlr_workspace_group_handle_v1_destroy(workspace_group_handle_); zext_workspace_group_handle_v1_destroy(workspace_group_handle_);
workspace_group_handle_ = nullptr; workspace_group_handle_ = nullptr;
workspace_manager_.remove_workspace_group(id_); workspace_manager_.remove_workspace_group(id_);
} }
@ -226,7 +226,7 @@ auto WorkspaceGroup::remove_button(Gtk::Button &button) -> void {
} }
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) zext_workspace_handle_v1 *workspace, uint32_t id)
: bar_(bar), : bar_(bar),
config_(config), config_(config),
workspace_group_(workspace_group), workspace_group_(workspace_group),
@ -267,7 +267,7 @@ Workspace::~Workspace() {
return; return;
} }
zwlr_workspace_handle_v1_destroy(workspace_handle_); zext_workspace_handle_v1_destroy(workspace_handle_);
workspace_handle_ = nullptr; workspace_handle_ = nullptr;
} }
@ -280,7 +280,7 @@ auto Workspace::handle_state(const std::vector<uint32_t> &state) -> void {
state_ = 0; state_ = 0;
for (auto state_entry : state) { for (auto state_entry : state) {
switch (state_entry) { switch (state_entry) {
case ZWLR_WORKSPACE_HANDLE_V1_STATE_ACTIVE: case ZEXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE:
state_ |= (uint32_t)State::ACTIVE; state_ |= (uint32_t)State::ACTIVE;
break; break;
} }
@ -288,7 +288,7 @@ auto Workspace::handle_state(const std::vector<uint32_t> &state) -> void {
} }
auto Workspace::handle_remove() -> void { auto Workspace::handle_remove() -> void {
zwlr_workspace_handle_v1_destroy(workspace_handle_); zext_workspace_handle_v1_destroy(workspace_handle_);
workspace_handle_ = nullptr; workspace_handle_ = nullptr;
workspace_group_.remove_workspace(id_); workspace_group_.remove_workspace(id_);
} }
@ -326,7 +326,7 @@ auto Workspace::get_icon() -> std::string {
auto Workspace::handle_clicked() -> void { auto Workspace::handle_clicked() -> void {
spdlog::debug("Workspace {} clicked", (void *)workspace_handle_); spdlog::debug("Workspace {} clicked", (void *)workspace_handle_);
zwlr_workspace_handle_v1_activate(workspace_handle_); zext_workspace_handle_v1_activate(workspace_handle_);
workspace_group_.commit(); workspace_group_.commit();
} }

View File

@ -9,7 +9,7 @@ namespace waybar::modules::wlr {
static void handle_global(void *data, wl_registry *registry, uint32_t name, const char *interface, static void handle_global(void *data, wl_registry *registry, uint32_t name, const char *interface,
uint32_t version) { uint32_t version) {
if (std::strcmp(interface, zwlr_workspace_manager_v1_interface.name) == 0) { if (std::strcmp(interface, zext_workspace_manager_v1_interface.name) == 0) {
static_cast<WorkspaceManager *>(data)->register_manager(registry, name, version); static_cast<WorkspaceManager *>(data)->register_manager(registry, name, version);
} }
} }
@ -31,72 +31,72 @@ void add_registry_listener(void *data) {
} }
static void workspace_manager_handle_workspace_group( static void workspace_manager_handle_workspace_group(
void *data, zwlr_workspace_manager_v1 *_, zwlr_workspace_group_handle_v1 *workspace_group) { void *data, zext_workspace_manager_v1 *_, zext_workspace_group_handle_v1 *workspace_group) {
static_cast<WorkspaceManager *>(data)->handle_workspace_group_create(workspace_group); static_cast<WorkspaceManager *>(data)->handle_workspace_group_create(workspace_group);
} }
static void workspace_manager_handle_done(void *data, zwlr_workspace_manager_v1 *_) { static void workspace_manager_handle_done(void *data, zext_workspace_manager_v1 *_) {
static_cast<WorkspaceManager *>(data)->handle_done(); static_cast<WorkspaceManager *>(data)->handle_done();
} }
static void workspace_manager_handle_finished(void *data, zwlr_workspace_manager_v1 *_) { static void workspace_manager_handle_finished(void *data, zext_workspace_manager_v1 *_) {
static_cast<WorkspaceManager *>(data)->handle_finished(); static_cast<WorkspaceManager *>(data)->handle_finished();
} }
static const zwlr_workspace_manager_v1_listener workspace_manager_impl = { static const zext_workspace_manager_v1_listener workspace_manager_impl = {
.workspace_group = workspace_manager_handle_workspace_group, .workspace_group = workspace_manager_handle_workspace_group,
.done = workspace_manager_handle_done, .done = workspace_manager_handle_done,
.finished = workspace_manager_handle_finished, .finished = workspace_manager_handle_finished,
}; };
zwlr_workspace_manager_v1 *workspace_manager_bind(wl_registry *registry, uint32_t name, zext_workspace_manager_v1 *workspace_manager_bind(wl_registry *registry, uint32_t name,
uint32_t version, void *data) { uint32_t version, void *data) {
auto *workspace_manager = static_cast<zwlr_workspace_manager_v1 *>( auto *workspace_manager = static_cast<zext_workspace_manager_v1 *>(
wl_registry_bind(registry, name, &zwlr_workspace_manager_v1_interface, version)); wl_registry_bind(registry, name, &zext_workspace_manager_v1_interface, version));
if (workspace_manager) if (workspace_manager)
zwlr_workspace_manager_v1_add_listener(workspace_manager, &workspace_manager_impl, data); zext_workspace_manager_v1_add_listener(workspace_manager, &workspace_manager_impl, data);
else else
spdlog::error("Failed to register manager"); spdlog::error("Failed to register manager");
return workspace_manager; return workspace_manager;
} }
static void workspace_group_handle_output_enter(void *data, zwlr_workspace_group_handle_v1 *_, static void workspace_group_handle_output_enter(void *data, zext_workspace_group_handle_v1 *_,
wl_output *output) { wl_output *output) {
static_cast<WorkspaceGroup *>(data)->handle_output_enter(output); static_cast<WorkspaceGroup *>(data)->handle_output_enter(output);
} }
static void workspace_group_handle_output_leave(void *data, zwlr_workspace_group_handle_v1 *_, static void workspace_group_handle_output_leave(void *data, zext_workspace_group_handle_v1 *_,
wl_output *output) { wl_output *output) {
static_cast<WorkspaceGroup *>(data)->handle_output_leave(); static_cast<WorkspaceGroup *>(data)->handle_output_leave();
} }
static void workspace_group_handle_workspace(void *data, zwlr_workspace_group_handle_v1 *_, static void workspace_group_handle_workspace(void *data, zext_workspace_group_handle_v1 *_,
zwlr_workspace_handle_v1 *workspace) { zext_workspace_handle_v1 *workspace) {
static_cast<WorkspaceGroup *>(data)->handle_workspace_create(workspace); static_cast<WorkspaceGroup *>(data)->handle_workspace_create(workspace);
} }
static void workspace_group_handle_remove(void *data, zwlr_workspace_group_handle_v1 *_) { static void workspace_group_handle_remove(void *data, zext_workspace_group_handle_v1 *_) {
static_cast<WorkspaceGroup *>(data)->handle_remove(); static_cast<WorkspaceGroup *>(data)->handle_remove();
} }
static const zwlr_workspace_group_handle_v1_listener workspace_group_impl = { static const zext_workspace_group_handle_v1_listener workspace_group_impl = {
.output_enter = workspace_group_handle_output_enter, .output_enter = workspace_group_handle_output_enter,
.output_leave = workspace_group_handle_output_leave, .output_leave = workspace_group_handle_output_leave,
.workspace = workspace_group_handle_workspace, .workspace = workspace_group_handle_workspace,
.remove = workspace_group_handle_remove}; .remove = workspace_group_handle_remove};
void add_workspace_group_listener(zwlr_workspace_group_handle_v1 *workspace_group_handle, void add_workspace_group_listener(zext_workspace_group_handle_v1 *workspace_group_handle,
void * data) { void * data) {
zwlr_workspace_group_handle_v1_add_listener(workspace_group_handle, &workspace_group_impl, data); zext_workspace_group_handle_v1_add_listener(workspace_group_handle, &workspace_group_impl, data);
} }
void workspace_handle_name(void *data, struct zwlr_workspace_handle_v1 *_, const char *name) { void workspace_handle_name(void *data, struct zext_workspace_handle_v1 *_, const char *name) {
static_cast<Workspace *>(data)->handle_name(name); static_cast<Workspace *>(data)->handle_name(name);
} }
void workspace_handle_coordinates(void *data, struct zwlr_workspace_handle_v1 *_, void workspace_handle_coordinates(void *data, struct zext_workspace_handle_v1 *_,
struct wl_array *coordinates) { struct wl_array *coordinates) {
std::vector<uint32_t> coords_vec; std::vector<uint32_t> coords_vec;
auto coords = static_cast<uint32_t *>(coordinates->data); auto coords = static_cast<uint32_t *>(coordinates->data);
@ -107,16 +107,16 @@ void workspace_handle_coordinates(void *data, struct zwlr_workspace_handle_v1 *_
static_cast<Workspace *>(data)->handle_coordinates(coords_vec); static_cast<Workspace *>(data)->handle_coordinates(coords_vec);
} }
void workspace_handle_state(void *data, struct zwlr_workspace_handle_v1 *workspace_handle, void workspace_handle_state(void *data, struct zext_workspace_handle_v1 *workspace_handle,
struct wl_array *state) { struct wl_array *state) {
std::vector<uint32_t> state_vec; std::vector<uint32_t> state_vec;
auto states = static_cast<uint32_t *>(state->data); auto states = static_cast<uint32_t *>(state->data);
for (size_t i = 0; i < state->size; ++i) { for (size_t i = 0; i < state->size; ++i) {
// To sync server and pending states // To sync server and pending states
if (states[i] == ZWLR_WORKSPACE_HANDLE_V1_STATE_ACTIVE) { if (states[i] == ZEXT_WORKSPACE_HANDLE_V1_STATE_ACTIVE) {
zwlr_workspace_handle_v1_activate(workspace_handle); zext_workspace_handle_v1_activate(workspace_handle);
} else { } else {
zwlr_workspace_handle_v1_deactivate(workspace_handle); zext_workspace_handle_v1_deactivate(workspace_handle);
} }
state_vec.push_back(states[i]); state_vec.push_back(states[i]);
} }
@ -124,17 +124,17 @@ void workspace_handle_state(void *data, struct zwlr_workspace_handle_v1 *workspa
static_cast<Workspace *>(data)->handle_state(state_vec); static_cast<Workspace *>(data)->handle_state(state_vec);
} }
void workspace_handle_remove(void *data, struct zwlr_workspace_handle_v1 *_) { void workspace_handle_remove(void *data, struct zext_workspace_handle_v1 *_) {
static_cast<Workspace *>(data)->handle_remove(); static_cast<Workspace *>(data)->handle_remove();
} }
static const zwlr_workspace_handle_v1_listener workspace_impl = { static const zext_workspace_handle_v1_listener workspace_impl = {
.name = workspace_handle_name, .name = workspace_handle_name,
.coordinates = workspace_handle_coordinates, .coordinates = workspace_handle_coordinates,
.state = workspace_handle_state, .state = workspace_handle_state,
.remove = workspace_handle_remove}; .remove = workspace_handle_remove};
void add_workspace_listener(zwlr_workspace_handle_v1 *workspace_handle, void *data) { void add_workspace_listener(zext_workspace_handle_v1 *workspace_handle, void *data) {
zwlr_workspace_handle_v1_add_listener(workspace_handle, &workspace_impl, data); zext_workspace_handle_v1_add_listener(workspace_handle, &workspace_impl, data);
} }
} // namespace waybar::modules::wlr } // namespace waybar::modules::wlr