Merge pull request #2185 from xdavidel/dwl-module

Update to new ipc version
pull/2200/head
Alex 2023-05-29 09:16:22 +02:00 committed by GitHub
commit 13a9c4a08b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 55 deletions

View File

@ -5,7 +5,7 @@
#include "AModule.hpp" #include "AModule.hpp"
#include "bar.hpp" #include "bar.hpp"
#include "dwl-bar-ipc-unstable-v1-client-protocol.h" #include "dwl-ipc-unstable-v2-client-protocol.h"
#include "xdg-output-unstable-v1-client-protocol.h" #include "xdg-output-unstable-v1-client-protocol.h"
namespace waybar::modules::dwl { namespace waybar::modules::dwl {
@ -21,14 +21,14 @@ class Tags : public waybar::AModule {
void handle_primary_clicked(uint32_t tag); void handle_primary_clicked(uint32_t tag);
bool handle_button_press(GdkEventButton *event_button, uint32_t tag); bool handle_button_press(GdkEventButton *event_button, uint32_t tag);
struct zdwl_manager_v1 *status_manager_; struct zdwl_ipc_manager_v2 *status_manager_;
struct wl_seat *seat_; struct wl_seat *seat_;
private: private:
const waybar::Bar &bar_; const waybar::Bar &bar_;
Gtk::Box box_; Gtk::Box box_;
std::vector<Gtk::Button> buttons_; std::vector<Gtk::Button> buttons_;
struct zdwl_output_v1 *output_status_; struct zdwl_ipc_output_v2 *output_status_;
}; };
} /* namespace waybar::modules::dwl */ } /* namespace waybar::modules::dwl */

View File

@ -3,9 +3,9 @@
This is largely ripped from somebar's ipc patchset; just with some personal modifications. This is largely ripped from somebar's ipc patchset; just with some personal modifications.
I would probably just submit raphi's patchset but I don't think that would be polite. I would probably just submit raphi's patchset but I don't think that would be polite.
--> -->
<protocol name="dwl_bar_ipc_unstable_v1"> <protocol name="dwl_ipc_unstable_v2">
<description summary="inter-proccess-communication about dwl's state"> <description summary="inter-proccess-communication about dwl's state">
This protocol allows clients to get updates from dwl and vice versa. This protocol allows clients to update and get updates from dwl.
Warning! The protocol described in this file is experimental and Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible backward incompatible changes may be made. Backward compatible
@ -19,36 +19,36 @@ I would probably just submit raphi's patchset but I don't think that would be po
reset. reset.
</description> </description>
<interface name="zdwl_manager_v1" version="3"> <interface name="zdwl_ipc_manager_v2" version="1">
<description summary="manage dwl state"> <description summary="manage dwl state">
This interface is exposed as a global in wl_registry. This interface is exposed as a global in wl_registry.
Clients can use this interface to get a dwl_output. Clients can use this interface to get a dwl_ipc_output.
After binding the client will revieve dwl_manager.tag and dwl_manager.layout events. After binding the client will recieve the dwl_ipc_manager.tags and dwl_ipc_manager.layout events.
The dwl_manager.tag and dwl_manager.layout events expose tags and layouts to the client. The dwl_ipc_manager.tags and dwl_ipc_manager.layout events expose tags and layouts to the client.
</description> </description>
<request name="release" type="destructor"> <request name="release" type="destructor">
<description summary="release dwl_manager"> <description summary="release dwl_ipc_manager">
Indicates that the client will not the dwl_manager object anymore. Indicates that the client will not the dwl_ipc_manager object anymore.
Objects created through this instance are not affected. Objects created through this instance are not affected.
</description> </description>
</request> </request>
<request name="get_output"> <request name="get_output">
<description summary="get a dwl_output for a wl_output"> <description summary="get a dwl_ipc_outout for a wl_output">
Get a dwl_output for the specified wl_output. Get a dwl_ipc_outout for the specified wl_output.
</description> </description>
<arg name="id" type="new_id" interface="zdwl_output_v1"/> <arg name="id" type="new_id" interface="zdwl_ipc_output_v2"/>
<arg name="output" type="object" interface="wl_output"/> <arg name="output" type="object" interface="wl_output"/>
</request> </request>
<event name="tag"> <event name="tags">
<description summary="Announces a tag"> <description summary="Announces tag amount">
This event is sent after binding. This event is sent after binding.
A roundtrip after binding guarantees the client recieved all tags. A roundtrip after binding guarantees the client recieved all tags.
</description> </description>
<arg name="tag" type="int"/> <arg name="amount" type="uint"/>
</event> </event>
<event name="layout"> <event name="layout">
@ -60,12 +60,12 @@ I would probably just submit raphi's patchset but I don't think that would be po
</event> </event>
</interface> </interface>
<interface name="zdwl_output_v1" version="3"> <interface name="zdwl_ipc_output_v2" version="1">
<description summary="control dwl output"> <description summary="control dwl output">
Observe and control a dwl output. Observe and control a dwl output.
Events are double-buffered: Events are double-buffered:
Clients should cache events and redraw when a dwl_output.done event is sent. Clients should cache events and redraw when a dwl_ipc_output.frame event is sent.
Request are not double-buffered: Request are not double-buffered:
The compositor will update immediately upon request. The compositor will update immediately upon request.
@ -78,8 +78,8 @@ I would probably just submit raphi's patchset but I don't think that would be po
</enum> </enum>
<request name="release" type="destructor"> <request name="release" type="destructor">
<description summary="release dwl_output"> <description summary="release dwl_ipc_outout">
Indicates to that the client no longer needs this dwl_output. Indicates to that the client no longer needs this dwl_ipc_output.
</description> </description>
</request> </request>
@ -121,34 +121,28 @@ I would probably just submit raphi's patchset but I don't think that would be po
<arg name="title" type="string" summary="The new title name."/> <arg name="title" type="string" summary="The new title name."/>
</event> </event>
<event name="appid" since="2"> <event name="appid" since="1">
<description summary="Update the appid."> <description summary="Update the appid.">
Indicates the appid has changed. Indicates the appid has changed.
</description> </description>
<arg name="appid" type="string" summary="The new appid."/> <arg name="appid" type="string" summary="The new appid."/>
</event> </event>
<event name="layout_symbol" since="3"> <event name="layout_symbol" since="1">
<description summary="Update the current layout symbol"> <description summary="Update the current layout symbol">
Indicates the layout has changed. Since layout symbols are now dynamic. Indicates the layout has changed. Since layout symbols are dynamic.
As opposed to the zdwl_manager_v1.layout event, this should take precendence when displaying. As opposed to the zdwl_ipc_manager.layout event, this should take precendence when displaying.
This also means ignoring the zdwl_output_v1.layout event. You can ignore the zdwl_ipc_output.layout event.
</description> </description>
<arg name="layout" type="string" summary="The new layout"/> <arg name="layout" type="string" summary="The new layout"/>
</event> </event>
<event name="frame"> <event name="frame">
<description summary="The update sequence is done."> <description summary="The update sequence is done.">
Indicates that a sequence of status updates have finished and the client should redraw. Indicates that a sequence of status updates have finished and the client should redraw.
</description> </description>
</event> </event>
<request name="set_layout">
<description summary="Set the layout of this output"/>
<arg name="index" type="uint" summary="index of a layout recieved by dwl_manager.layout"/>
</request>
<request name="set_tags"> <request name="set_tags">
<description summary="Set the active tags of this output"/> <description summary="Set the active tags of this output"/>
<arg name="tagmask" type="uint" summary="bitmask of the tags that should be set."/> <arg name="tagmask" type="uint" summary="bitmask of the tags that should be set."/>
@ -163,5 +157,10 @@ I would probably just submit raphi's patchset but I don't think that would be po
<arg name="and_tags" type="uint"/> <arg name="and_tags" type="uint"/>
<arg name="xor_tags" type="uint"/> <arg name="xor_tags" type="uint"/>
</request> </request>
<request name="set_layout">
<description summary="Set the layout of this output"/>
<arg name="index" type="uint" summary="index of a layout recieved by dwl_ipc_manager.layout"/>
</request>
</interface> </interface>
</protocol> </protocol>

View File

@ -30,7 +30,7 @@ client_protocols = [
['ext-workspace-unstable-v1.xml'], ['ext-workspace-unstable-v1.xml'],
['river-status-unstable-v1.xml'], ['river-status-unstable-v1.xml'],
['river-control-unstable-v1.xml'], ['river-control-unstable-v1.xml'],
['dwl-bar-ipc-unstable-v1.xml'], ['dwl-ipc-unstable-v2.xml'],
] ]
client_protos_src = [] client_protos_src = []

View File

@ -8,7 +8,7 @@
#include <algorithm> #include <algorithm>
#include "client.hpp" #include "client.hpp"
#include "dwl-bar-ipc-unstable-v1-client-protocol.h" #include "dwl-ipc-unstable-v2-client-protocol.h"
#define TAG_INACTIVE 0 #define TAG_INACTIVE 0
#define TAG_ACTIVE 1 #define TAG_ACTIVE 1
@ -21,43 +21,43 @@ wl_array tags, layouts;
static uint num_tags = 0; static uint num_tags = 0;
void toggle_visibility(void *data, zdwl_output_v1 *zdwl_output_v1) { void toggle_visibility(void *data, zdwl_ipc_output_v2 *zdwl_output_v2) {
// Intentionally empty // Intentionally empty
} }
void active(void *data, zdwl_output_v1 *zdwl_output_v1, uint32_t active) { void active(void *data, zdwl_ipc_output_v2 *zdwl_output_v2, uint32_t active) {
// Intentionally empty // Intentionally empty
} }
static void set_tag(void *data, zdwl_output_v1 *zdwl_output_v1, uint32_t tag, uint32_t state, static void set_tag(void *data, zdwl_ipc_output_v2 *zdwl_output_v2, uint32_t tag, uint32_t state,
uint32_t clients, uint32_t focused) { uint32_t clients, uint32_t focused) {
static_cast<Tags *>(data)->handle_view_tags(tag, state, clients, focused); static_cast<Tags *>(data)->handle_view_tags(tag, state, clients, focused);
num_tags = num_tags = (state & ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE) ? num_tags | (1 << tag)
(state & ZDWL_OUTPUT_V1_TAG_STATE_ACTIVE) ? num_tags | (1 << tag) : num_tags & ~(1 << tag); : num_tags & ~(1 << tag);
} }
void set_layout_symbol(void *data, zdwl_output_v1 *zdwl_output_v1, const char *layout) { void set_layout_symbol(void *data, zdwl_ipc_output_v2 *zdwl_output_v2, const char *layout) {
// Intentionally empty // Intentionally empty
} }
void title(void *data, zdwl_output_v1 *zdwl_output_v1, const char *title) { void title(void *data, zdwl_ipc_output_v2 *zdwl_output_v2, const char *title) {
// Intentionally empty // Intentionally empty
} }
void dwl_frame(void *data, zdwl_output_v1 *zdwl_output_v1) { void dwl_frame(void *data, zdwl_ipc_output_v2 *zdwl_output_v2) {
// Intentionally empty // Intentionally empty
} }
static void set_layout(void *data, zdwl_output_v1 *zdwl_output_v1, uint32_t layout) { static void set_layout(void *data, zdwl_ipc_output_v2 *zdwl_output_v2, uint32_t layout) {
// Intentionally empty // Intentionally empty
} }
static void appid(void *data, zdwl_output_v1 *zdwl_output_v1, const char *appid){ static void appid(void *data, zdwl_ipc_output_v2 *zdwl_output_v2, const char *appid){
// Intentionally empty // Intentionally empty
}; };
static const zdwl_output_v1_listener output_status_listener_impl{ static const zdwl_ipc_output_v2_listener output_status_listener_impl{
.toggle_visibility = toggle_visibility, .toggle_visibility = toggle_visibility,
.active = active, .active = active,
.tag = set_tag, .tag = set_tag,
@ -70,9 +70,9 @@ static const zdwl_output_v1_listener output_status_listener_impl{
static void handle_global(void *data, struct wl_registry *registry, uint32_t name, static void handle_global(void *data, struct wl_registry *registry, uint32_t name,
const char *interface, uint32_t version) { const char *interface, uint32_t version) {
if (std::strcmp(interface, zdwl_manager_v1_interface.name) == 0) { if (std::strcmp(interface, zdwl_ipc_manager_v2_interface.name) == 0) {
static_cast<Tags *>(data)->status_manager_ = static_cast<struct zdwl_manager_v1 *>( static_cast<Tags *>(data)->status_manager_ = static_cast<struct zdwl_ipc_manager_v2 *>(
(zdwl_manager_v1 *)wl_registry_bind(registry, name, &zdwl_manager_v1_interface, 3)); (zdwl_ipc_manager_v2 *)wl_registry_bind(registry, name, &zdwl_ipc_manager_v2_interface, 3));
} }
if (std::strcmp(interface, wl_seat_interface.name) == 0) { if (std::strcmp(interface, wl_seat_interface.name) == 0) {
version = std::min<uint32_t>(version, 1); version = std::min<uint32_t>(version, 1);
@ -101,7 +101,7 @@ Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &con
wl_display_roundtrip(display); wl_display_roundtrip(display);
if (!status_manager_) { if (!status_manager_) {
spdlog::error("dwl_status_manager_v1 not advertised"); spdlog::error("dwl_status_manager_v2 not advertised");
return; return;
} }
@ -146,29 +146,29 @@ Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &con
} }
struct wl_output *output = gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj()); struct wl_output *output = gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj());
output_status_ = zdwl_manager_v1_get_output(status_manager_, output); output_status_ = zdwl_ipc_manager_v2_get_output(status_manager_, output);
zdwl_output_v1_add_listener(output_status_, &output_status_listener_impl, this); zdwl_ipc_output_v2_add_listener(output_status_, &output_status_listener_impl, this);
zdwl_manager_v1_destroy(status_manager_); zdwl_ipc_manager_v2_destroy(status_manager_);
status_manager_ = nullptr; status_manager_ = nullptr;
} }
Tags::~Tags() { Tags::~Tags() {
if (status_manager_) { if (status_manager_) {
zdwl_manager_v1_destroy(status_manager_); zdwl_ipc_manager_v2_destroy(status_manager_);
} }
} }
void Tags::handle_primary_clicked(uint32_t tag) { void Tags::handle_primary_clicked(uint32_t tag) {
if (!output_status_) return; if (!output_status_) return;
zdwl_output_v1_set_tags(output_status_, tag, 1); zdwl_ipc_output_v2_set_tags(output_status_, tag, 1);
} }
bool Tags::handle_button_press(GdkEventButton *event_button, uint32_t tag) { bool Tags::handle_button_press(GdkEventButton *event_button, uint32_t tag) {
if (event_button->type == GDK_BUTTON_PRESS && event_button->button == 3) { if (event_button->type == GDK_BUTTON_PRESS && event_button->button == 3) {
if (!output_status_) return true; if (!output_status_) return true;
zdwl_output_v1_set_tags(output_status_, num_tags ^ tag, 0); zdwl_ipc_output_v2_set_tags(output_status_, num_tags ^ tag, 0);
} }
return true; return true;
} }