diff options
Diffstat (limited to 'src/helpers.rs')
-rw-r--r-- | src/helpers.rs | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/helpers.rs b/src/helpers.rs index 24c8cf2..cc76e43 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,6 +1,9 @@ //! Helpers for writing configuration -use crate::WM; +use crate::{ + clients::{Tag, TagFocus}, + WM, +}; use std::{ffi::OsStr, process::Command}; /// Syntax sugar for creating [`Keybind`]s. This is helpful for writing [`crate::config::KEYBINDS`] @@ -12,9 +15,21 @@ use std::{ffi::OsStr, process::Command}; #[macro_export] macro_rules! bind { ($mod:expr , $key:ident -> $action:expr) => { - Keybind { + $crate::keys::Keybind { modifiers: $mod, - key: Keysym::$key, + key: ::xkeysym::Keysym::$key, + action: $action, + } + }; +} + +/// Syntax sugar for creating [`ButtonBind`]s. See also: [`self::bind`]. +#[macro_export] +macro_rules! bind_btn { + ($mod:expr , $key:ident -> $action:expr) => { + $crate::buttons::ButtonBind { + modifiers: $mod, + button: ::xcb::x::ButtonIndex::$key, action: $action, } }; @@ -54,3 +69,16 @@ pub fn toggle_fullscreen(wm: &mut WM<'_>) { wm.clients.toggle_fullscreen(&wm.conn, pos); } } + +/// Set the focused tag for the currently selected monitor +pub fn set_tag_focus(wm: &mut WM<'_>, tag_focus: TagFocus) { + wm.clients + .set_mon_tag_focus(&wm.conn, wm.clients.focused_mon(), tag_focus); +} + +/// Set the tag for the currently selected client +pub fn set_tag(wm: &mut WM<'_>, tag: Tag) { + if let Some(pos) = wm.clients.focused_pos() { + wm.clients.set_client_tag(&wm.conn, pos, tag); + } +} |