mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-26 21:58:10 +01:00
Add docs
This commit is contained in:
parent
2427ba620e
commit
1abc17b5b4
2 changed files with 27 additions and 8 deletions
|
@ -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::{
|
use std::{
|
||||||
collections::{btree_map, BTreeMap},
|
collections::{btree_map, BTreeMap},
|
||||||
|
@ -89,7 +95,7 @@ macro_rules! signals {
|
||||||
self.callback_count.clone(),
|
self.callback_count.clone(),
|
||||||
|out| {
|
|out| {
|
||||||
block_on_tokio(self.client.$req(out))
|
block_on_tokio(self.client.$req(out))
|
||||||
.expect("TODO")
|
.expect("failed to request signal connection")
|
||||||
.into_inner()
|
.into_inner()
|
||||||
},
|
},
|
||||||
$on_resp,
|
$on_resp,
|
||||||
|
@ -114,6 +120,11 @@ signals! {
|
||||||
/// Signals relating to tag events.
|
/// Signals relating to tag events.
|
||||||
TagSignal => {
|
TagSignal => {
|
||||||
/// The compositor requested that the given windows be laid out.
|
/// 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 = {
|
Layout = {
|
||||||
enum_name = Layout,
|
enum_name = Layout,
|
||||||
callback_type = LayoutFn,
|
callback_type = LayoutFn,
|
||||||
|
@ -140,6 +151,11 @@ signals! {
|
||||||
/// Signals relating to output events.
|
/// Signals relating to output events.
|
||||||
OutputSignal => {
|
OutputSignal => {
|
||||||
/// An output was connected.
|
/// 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 = {
|
OutputConnect = {
|
||||||
enum_name = Connect,
|
enum_name = Connect,
|
||||||
callback_type = SingleOutputFn,
|
callback_type = SingleOutputFn,
|
||||||
|
@ -159,6 +175,8 @@ signals! {
|
||||||
/// Signals relating to window events.
|
/// Signals relating to window events.
|
||||||
WindowSignal => {
|
WindowSignal => {
|
||||||
/// The pointer entered a window.
|
/// The pointer entered a window.
|
||||||
|
///
|
||||||
|
/// Callbacks receive the window the pointer entered.
|
||||||
WindowPointerEnter = {
|
WindowPointerEnter = {
|
||||||
enum_name = PointerEnter,
|
enum_name = PointerEnter,
|
||||||
callback_type = SingleWindowFn,
|
callback_type = SingleWindowFn,
|
||||||
|
@ -175,6 +193,8 @@ signals! {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
/// The pointer left a window.
|
/// The pointer left a window.
|
||||||
|
///
|
||||||
|
/// Callbacks receive the window the pointer left.
|
||||||
WindowPointerLeave = {
|
WindowPointerLeave = {
|
||||||
enum_name = PointerLeave,
|
enum_name = PointerLeave,
|
||||||
callback_type = SingleWindowFn,
|
callback_type = SingleWindowFn,
|
||||||
|
@ -300,11 +320,12 @@ where
|
||||||
match response {
|
match response {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
on_response(response, callbacks.values_mut());
|
on_response(response, callbacks.values_mut());
|
||||||
tokio::task::yield_now().await;
|
|
||||||
|
|
||||||
control_sender
|
control_sender
|
||||||
.send(Req::from_control(StreamControl::Ready))
|
.send(Req::from_control(StreamControl::Ready))
|
||||||
.expect("send failed");
|
.expect("send failed");
|
||||||
|
|
||||||
|
tokio::task::yield_now().await;
|
||||||
}
|
}
|
||||||
Err(status) => eprintln!("Error in recv: {status}"),
|
Err(status) => eprintln!("Error in recv: {status}"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,12 +122,12 @@ impl Window {
|
||||||
/// ```
|
/// ```
|
||||||
/// let windows = window.get_all();
|
/// 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())
|
block_on_tokio(self.get_all_async())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The async version of [`Window::get_all`].
|
/// 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();
|
let mut client = self.window_client.clone();
|
||||||
client
|
client
|
||||||
.get(GetRequest {})
|
.get(GetRequest {})
|
||||||
|
@ -138,8 +138,6 @@ impl Window {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(move |id| self.new_handle(id))
|
.map(move |id| self.new_handle(id))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
// TODO: consider changing return type to Vec to avoid this into_iter
|
|
||||||
.into_iter()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the currently focused window.
|
/// 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.
|
/// 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.
|
/// 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) {
|
pub fn add_window_rule(&self, cond: WindowRuleCondition, rule: WindowRule) {
|
||||||
let mut client = self.window_client.clone();
|
let mut client = self.window_client.clone();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue