This commit is contained in:
Ottatop 2024-02-23 17:15:55 -06:00
parent 2427ba620e
commit 1abc17b5b4
2 changed files with 27 additions and 8 deletions

View file

@ -1,4 +1,10 @@
//! Signals TODO:
//! Compositor signals.
//!
//! Your config can connect to various compositor signals that allow you to, for example, do
//! something when an output is connected or when the pointer enters a window.
//!
//! Some of the other modules have a `connect_signal` method that will allow you to pass in
//! callbacks to run on each signal. Use them to connect to the signals defined here.
use std::{
collections::{btree_map, BTreeMap},
@ -89,7 +95,7 @@ macro_rules! signals {
self.callback_count.clone(),
|out| {
block_on_tokio(self.client.$req(out))
.expect("TODO")
.expect("failed to request signal connection")
.into_inner()
},
$on_resp,
@ -114,6 +120,11 @@ signals! {
/// Signals relating to tag events.
TagSignal => {
/// The compositor requested that the given windows be laid out.
///
/// Callbacks receive the tag that is being laid out and the windows being laid out.
///
/// Note: if multiple tags are active, only the first will be received, but all windows on those
/// active tags will be received.
Layout = {
enum_name = Layout,
callback_type = LayoutFn,
@ -140,6 +151,11 @@ signals! {
/// Signals relating to output events.
OutputSignal => {
/// An output was connected.
///
/// Callbacks receive the newly connected output.
///
/// FIXME: This will not run on outputs that have been previously connected.
/// | Tell the dev to fix this in the compositor.
OutputConnect = {
enum_name = Connect,
callback_type = SingleOutputFn,
@ -159,6 +175,8 @@ signals! {
/// Signals relating to window events.
WindowSignal => {
/// The pointer entered a window.
///
/// Callbacks receive the window the pointer entered.
WindowPointerEnter = {
enum_name = PointerEnter,
callback_type = SingleWindowFn,
@ -175,6 +193,8 @@ signals! {
},
}
/// The pointer left a window.
///
/// Callbacks receive the window the pointer left.
WindowPointerLeave = {
enum_name = PointerLeave,
callback_type = SingleWindowFn,
@ -300,11 +320,12 @@ where
match response {
Ok(response) => {
on_response(response, callbacks.values_mut());
tokio::task::yield_now().await;
control_sender
.send(Req::from_control(StreamControl::Ready))
.expect("send failed");
tokio::task::yield_now().await;
}
Err(status) => eprintln!("Error in recv: {status}"),
}

View file

@ -122,12 +122,12 @@ impl Window {
/// ```
/// let windows = window.get_all();
/// ```
pub fn get_all(&self) -> impl Iterator<Item = WindowHandle> {
pub fn get_all(&self) -> Vec<WindowHandle> {
block_on_tokio(self.get_all_async())
}
/// The async version of [`Window::get_all`].
pub async fn get_all_async(&self) -> impl Iterator<Item = WindowHandle> {
pub async fn get_all_async(&self) -> Vec<WindowHandle> {
let mut client = self.window_client.clone();
client
.get(GetRequest {})
@ -138,8 +138,6 @@ impl Window {
.into_iter()
.map(move |id| self.new_handle(id))
.collect::<Vec<_>>()
// TODO: consider changing return type to Vec to avoid this into_iter
.into_iter()
}
/// Get the currently focused window.
@ -166,7 +164,7 @@ impl Window {
/// A window rule is a set of criteria that a window must open with.
/// For it to apply, a [`WindowRuleCondition`] must evaluate to true for the window in question.
///
/// TODO:
/// See the [`rules`] module for more information.
pub fn add_window_rule(&self, cond: WindowRuleCondition, rule: WindowRule) {
let mut client = self.window_client.clone();