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
40 changes: 10 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions watchers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ tempfile = "3.13.0"
[dependencies]
aw-client-rust = { git = "https://github.com/ActivityWatch/aw-server-rust", rev = "656f3c9" }
wayland-client = "0.31.7"
wayland-scanner = "0.31.6"
wayland-backend = "0.3.8"
wayland-protocols = { version = "0.32.5", features = ["staging", "client" ]}
wayland-protocols-plasma = { version = "0.3.5", features = ["client"] }
wayland-protocols-wlr = { version = "0.3.5", features = ["client"] }
Expand Down
6 changes: 6 additions & 0 deletions watchers/src/watchers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub mod idle;
#[cfg(feature = "kwin_window")]
mod kwin_window;
mod wl_connection;
mod wl_bindings;
mod wl_dwl_ipc;
mod wl_ext_idle_notify;
mod wl_foreign_toplevel_management;
mod wl_kwin_idle;
Expand Down Expand Up @@ -98,6 +100,10 @@ async fn filter_first_supported(
));
}
WatcherType::ActiveWindow => {
watch!(create_watcher::<wl_dwl_ipc::WindowWatcher>(
client,
"Wayland window (dwl-ipc-unstable-v2)"
));
watch!(create_watcher::<
wl_foreign_toplevel_management::WindowWatcher,
>(
Expand Down
177 changes: 177 additions & 0 deletions watchers/src/watchers/wl-protocols/dwl_ipc_unstable_v2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<protocol name="dwl_ipc_unstable_v2">
<description summary="inter-proccess-communication about dwl's state">
This protocol allows clients to update and get updates from dwl.

Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible
changes may be added together with the corresponding interface
version bump.
Backward incompatible changes are done by bumping the version
number in the protocol and interface names and resetting the
interface version. Once the protocol is to be declared stable,
the 'z' prefix and the version number in the protocol and
interface names are removed and the interface version number is
reset.
</description>

<interface name="zdwl_ipc_manager_v2" version="2">
<description summary="manage dwl state">
This interface is exposed as a global in wl_registry.

Clients can use this interface to get a dwl_ipc_output.
After binding the client will recieve the dwl_ipc_manager.tags and dwl_ipc_manager.layout events.
The dwl_ipc_manager.tags and dwl_ipc_manager.layout events expose tags and layouts to the client.
</description>

<request name="release" type="destructor">
<description summary="release dwl_ipc_manager">
Indicates that the client will not the dwl_ipc_manager object anymore.
Objects created through this instance are not affected.
</description>
</request>

<request name="get_output">
<description summary="get a dwl_ipc_outout for a wl_output">
Get a dwl_ipc_outout for the specified wl_output.
</description>
<arg name="id" type="new_id" interface="zdwl_ipc_output_v2"/>
<arg name="output" type="object" interface="wl_output"/>
</request>

<event name="tags">
<description summary="Announces tag amount">
This event is sent after binding.
A roundtrip after binding guarantees the client recieved all tags.
</description>
<arg name="amount" type="uint"/>
</event>

<event name="layout">
<description summary="Announces a layout">
This event is sent after binding.
A roundtrip after binding guarantees the client recieved all layouts.
</description>
<arg name="name" type="string"/>
</event>
</interface>

<interface name="zdwl_ipc_output_v2" version="2">
<description summary="control dwl output">
Observe and control a dwl output.

Events are double-buffered:
Clients should cache events and redraw when a dwl_ipc_output.frame event is sent.

Request are not double-buffered:
The compositor will update immediately upon request.
</description>

<enum name="tag_state">
<entry name="none" value="0" summary="no state"/>
<entry name="active" value="1" summary="tag is active"/>
<entry name="urgent" value="2" summary="tag has at least one urgent client"/>
</enum>

<request name="release" type="destructor">
<description summary="release dwl_ipc_outout">
Indicates to that the client no longer needs this dwl_ipc_output.
</description>
</request>

<event name="toggle_visibility">
<description summary="Toggle client visibilty">
Indicates the client should hide or show themselves.
If the client is visible then hide, if hidden then show.
</description>
</event>

<event name="active">
<description summary="Update the selected output.">
Indicates if the output is active. Zero is invalid, nonzero is valid.
</description>
<arg name="active" type="uint"/>
</event>

<event name="tag">
<description summary="Update the state of a tag.">
Indicates that a tag has been updated.
</description>
<arg name="tag" type="uint" summary="Index of the tag"/>
<arg name="state" type="uint" enum="tag_state" summary="The state of the tag."/>
<arg name="clients" type="uint" summary="The number of clients in the tag."/>
<arg name="focused" type="uint" summary="If there is a focused client. Nonzero being valid, zero being invalid."/>
</event>

<event name="layout">
<description summary="Update the layout.">
Indicates a new layout is selected.
</description>
<arg name="layout" type="uint" summary="Index of the layout."/>
</event>

<event name="title">
<description summary="Update the title.">
Indicates the title has changed.
</description>
<arg name="title" type="string" summary="The new title name."/>
</event>

<event name="appid" since="1">
<description summary="Update the appid.">
Indicates the appid has changed.
</description>
<arg name="appid" type="string" summary="The new appid."/>
</event>

<event name="layout_symbol" since="1">
<description summary="Update the current layout symbol">
Indicates the layout has changed. Since layout symbols are dynamic.
As opposed to the zdwl_ipc_manager.layout event, this should take precendence when displaying.
You can ignore the zdwl_ipc_output.layout event.
</description>
<arg name="layout" type="string" summary="The new layout"/>
</event>

<event name="frame">
<description summary="The update sequence is done.">
Indicates that a sequence of status updates have finished and the client should redraw.
</description>
</event>

<request name="set_tags">
<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="toggle_tagset" type="uint" summary="toggle the selected tagset, zero for invalid, nonzero for valid."/>
</request>

<request name="set_client_tags">
<description summary="Set the tags of the focused client.">
The tags are updated as follows:
new_tags = (current_tags AND and_tags) XOR xor_tags
</description>
<arg name="and_tags" type="uint"/>
<arg name="xor_tags" type="uint"/>
</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>

<!-- Version 2 -->
<event name="fullscreen" since="2">
<description summary="Update fullscreen status">
Indicates if the selected client on this output is fullscreen.
</description>
<arg name="is_fullscreen" type="uint" summary="If the selected client is fullscreen. Nonzero is valid, zero invalid"/>
</event>

<event name="floating" since="2">
<description summary="Update the floating status">
Indicates if the selected client on this output is floating.
</description>
<arg name="is_floating" type="uint" summary="If the selected client is floating. Nonzero is valid, zero invalid"/>
</event>
</interface>
</protocol>
12 changes: 12 additions & 0 deletions watchers/src/watchers/wl_bindings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pub mod zdwl_ipc {
use wayland_client;
use wayland_client::protocol::*;

pub mod __interfaces {
use wayland_client::protocol::__interfaces::*;
wayland_scanner::generate_interfaces!("src/watchers/wl-protocols/dwl_ipc_unstable_v2.xml");
}
use self::__interfaces::*;

wayland_scanner::generate_client_code!("src/watchers/wl-protocols/dwl_ipc_unstable_v2.xml");
}
15 changes: 15 additions & 0 deletions watchers/src/watchers/wl_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use wayland_protocols_plasma::idle::client::{
};
use wayland_protocols_wlr::foreign_toplevel::v1::client::zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1;

use super::wl_bindings::zdwl_ipc::zdwl_ipc_manager_v2::ZdwlIpcManagerV2;

macro_rules! subscribe_state {
($struct_name:ty, $data_name:ty, $state:ty) => {
impl Dispatch<$struct_name, $data_name> for $state {
Expand Down Expand Up @@ -72,6 +74,19 @@ where
.map_err(std::convert::Into::into)
}

pub fn get_dwl_ipc_manager(&self) -> anyhow::Result<ZdwlIpcManagerV2>
where
T: Dispatch<ZdwlIpcManagerV2, ()>,
{
self.globals
.bind::<ZdwlIpcManagerV2, T, ()>(
&self.queue_handle,
1..=ZdwlIpcManagerV2::interface().version,
(),
)
.map_err(std::convert::Into::into)
}

pub fn get_kwin_idle(&self) -> anyhow::Result<OrgKdeKwinIdle>
where
T: Dispatch<OrgKdeKwinIdle, ()>,
Expand Down
Loading