Skip to content

Commit ba95792

Browse files
committed
simplify window positioning logic
1 parent 936559d commit ba95792

File tree

2 files changed

+19
-35
lines changed

2 files changed

+19
-35
lines changed

gridwm.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ gridwm = [
3434
["SUPER+C", "close"],
3535
["SUPER+RIGHT", "desktop_right"],
3636
["SUPER+LEFT", "desktop_left"],
37-
["ALT+Z", "unfloat"]
37+
["SUPER+Z", "unfloat"]
3838
]
3939
exec = [
4040
["SUPER+ENTER", "konsole"],
4141
["SUPER+SPACE", "rofi -show drun"]
4242
]
43-
move_mod = "ALT"
44-
resize_mod = "ALT"
43+
move_mod = "SUPER"
44+
resize_mod = "SUPER"

src/gridwm/mod.rs

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,38 +1099,22 @@ impl GridWM {
10991099
(0..n)
11001100
.map(|i| {
11011101
let i = i as i32;
1102-
if self.config.bar.enable && !self.config.window.window_bars {
1103-
WindowInfo {
1104-
x: (i % cols) * w,
1105-
y: ((i / cols) * h) + self.config.bar.height as i32,
1106-
w,
1107-
h,
1108-
}
1109-
} else if self.config.bar.enable && self.config.window.window_bars {
1110-
WindowInfo {
1111-
x: (i % cols) * w,
1112-
y: ((i / cols) * h)
1113-
+ self.config.bar.height as i32
1114-
+ (((i / cols) + 1) * self.config.window.window_bar_height as i32),
1115-
w,
1116-
h: h - self.config.window.window_bar_height as i32,
1117-
}
1118-
} else if !self.config.bar.enable && self.config.window.window_bars {
1119-
WindowInfo {
1120-
x: (i % cols) * w,
1121-
y: ((i / cols) * h)
1122-
+ (((i / cols) + 1) * self.config.window.window_bar_height as i32),
1123-
w,
1124-
h: h - self.config.window.window_bar_height as i32,
1125-
}
1126-
} else {
1127-
// bar disabled and window bars disabled
1128-
WindowInfo {
1129-
x: (i % cols) * w,
1130-
y: (i / cols) * h,
1131-
w,
1132-
h,
1133-
}
1102+
1103+
let bar_height = match self.config.bar.enable {
1104+
true => self.config.bar.height as i32,
1105+
false => 0,
1106+
};
1107+
1108+
let window_bar_height = match self.config.window.window_bars {
1109+
true => self.config.window.window_bar_height as i32,
1110+
false => 0,
1111+
};
1112+
1113+
WindowInfo {
1114+
x: (i % cols) * w,
1115+
y: ((i / cols) * h) + bar_height + window_bar_height,
1116+
w,
1117+
h: h - window_bar_height,
11341118
}
11351119
})
11361120
.collect()

0 commit comments

Comments
 (0)