summaryrefslogtreecommitdiff
path: root/src/helpers.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-06 14:39:55 +0100
committertcmal <me@aria.rip>2024-08-13 17:56:36 +0100
commitd973959f7f34e02eeb01766b01aff680639a8c4c (patch)
tree155aab05ad70915d0ebdf509e828765c0bac2822 /src/helpers.rs
parent89b5f3f87c8022f2d32c422c3516fca2f1538d69 (diff)
Add support for mouse button binds
Diffstat (limited to 'src/helpers.rs')
-rw-r--r--src/helpers.rs34
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);
+ }
+}