aboutsummaryrefslogtreecommitdiff
path: root/src/safe_x11
diff options
context:
space:
mode:
Diffstat (limited to 'src/safe_x11')
-rw-r--r--src/safe_x11/window.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/safe_x11/window.rs b/src/safe_x11/window.rs
index c889dfc..6d1e54e 100644
--- a/src/safe_x11/window.rs
+++ b/src/safe_x11/window.rs
@@ -252,6 +252,56 @@ impl XWindow {
}
}
+ pub fn resize_sticky_left(&self, boundaries: &[i32]) {
+ let attrs = self.attributes();
+
+ if let Some(v) = boundaries.iter()
+ .skip_while(|&a| *a >= attrs.x + attrs.width)
+ .next() {
+ let diff = attrs.width - (*v - attrs.x);
+ if *v - attrs.x > 0 {
+ let _ = self.resize_to(attrs.width - diff, attrs.height);
+ }
+ }
+ }
+
+ pub fn resize_sticky_right(&self, boundaries: &[i32]) {
+ let attrs = self.attributes();
+ let win_bound = attrs.x + attrs.width;
+
+ if let Some(v) = boundaries.iter()
+ .skip_while(|&a| *a <= win_bound)
+ .next() {
+ let new_width = *v - attrs.x;
+ let _ = self.resize_to(new_width, attrs.height);
+ }
+ }
+
+ pub fn resize_sticky_up(&self, boundaries: &[i32]) {
+ let attrs = self.attributes();
+
+ if let Some(v) = boundaries.iter()
+ .skip_while(|&a| *a >= attrs.y + attrs.height)
+ .next() {
+ let diff = attrs.height - (*v - attrs.y);
+ if *v - attrs.y > 0 {
+ let _ = self.resize_to(attrs.width, attrs.height - diff);
+ }
+ }
+ }
+
+ pub fn resize_sticky_down(&self, boundaries: &[i32]) {
+ let attrs = self.attributes();
+ let win_bound = attrs.y + attrs.height;
+
+ if let Some(v) = boundaries.iter()
+ .skip_while(|&a| *a <= win_bound)
+ .next() {
+ let new_height = *v - attrs.y;
+ let _ = self.resize_to(attrs.width, new_height);
+ }
+ }
+
/// Raise the focus of the window and set a border.
pub fn focus(&self) {
let attrs = self.attributes();