mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
feat(launcher): add option to minimize window if focused
This commit is contained in:
parent
9c13e534b7
commit
64b953ce5e
6 changed files with 58 additions and 7 deletions
|
@ -76,6 +76,8 @@ pub enum Request {
|
|||
ToplevelInfoAll,
|
||||
#[cfg(feature = "launcher")]
|
||||
ToplevelFocus(usize),
|
||||
#[cfg(feature = "launcher")]
|
||||
ToplevelMinimize(usize),
|
||||
|
||||
#[cfg(feature = "clipboard")]
|
||||
CopyToClipboard(ClipboardItem),
|
||||
|
@ -350,6 +352,19 @@ impl Environment {
|
|||
|
||||
send!(env.response_tx, Response::Ok);
|
||||
}
|
||||
#[cfg(feature = "launcher")]
|
||||
Msg(Request::ToplevelMinimize(id)) => {
|
||||
let handle = env
|
||||
.handles
|
||||
.iter()
|
||||
.find(|handle| handle.info().map_or(false, |info| info.id == id));
|
||||
|
||||
if let Some(handle) = handle {
|
||||
handle.minimize();
|
||||
}
|
||||
|
||||
send!(env.response_tx, Response::Ok);
|
||||
}
|
||||
#[cfg(feature = "clipboard")]
|
||||
Msg(Request::CopyToClipboard(item)) => {
|
||||
env.copy_to_clipboard(item);
|
||||
|
|
|
@ -33,6 +33,11 @@ impl ToplevelHandle {
|
|||
trace!("Activating handle");
|
||||
self.handle.activate(seat);
|
||||
}
|
||||
|
||||
pub fn minimize(&self) {
|
||||
trace!("Minimizing handle");
|
||||
self.handle.set_minimized();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
|
|
@ -36,6 +36,15 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
/// Minimizes the toplevel with the provided ID.
|
||||
#[cfg(feature = "launcher")]
|
||||
pub fn toplevel_minimize(&self, handle_id: usize) {
|
||||
match self.send_request(Request::ToplevelMinimize(handle_id)) {
|
||||
Response::Ok => (),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Subscribes to events from toplevels.
|
||||
pub fn subscribe_toplevels(&self) -> broadcast::Receiver<ToplevelEvent> {
|
||||
self.toplevel_channel.0.subscribe()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue