| @@ -243,7 +243,10 @@ impl WindowManager { |
| 243 |
)?; |
243 |
)?; |
| 244 |
} |
244 |
} |
| 245 |
|
245 |
|
| 246 |
- let monitors = detect_monitors(&connection, &screen, root)?; |
246 |
+ let mut monitors = detect_monitors(&connection, &screen, root)?; |
|
|
247 |
+ for monitor in monitors.iter_mut() { |
|
|
248 |
+ monitor.init_pertag(config.tags.len(), "tiling"); |
|
|
249 |
+ } |
| 247 |
|
250 |
|
| 248 |
let display = unsafe { x11::xlib::XOpenDisplay(std::ptr::null()) }; |
251 |
let display = unsafe { x11::xlib::XOpenDisplay(std::ptr::null()) }; |
| 249 |
if display.is_null() { |
252 |
if display.is_null() { |
| @@ -710,6 +713,9 @@ impl WindowManager { |
| 710 |
if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
713 |
if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
| 711 |
let new_mfact = (monitor.master_factor + delta).clamp(0.05, 0.95); |
714 |
let new_mfact = (monitor.master_factor + delta).clamp(0.05, 0.95); |
| 712 |
monitor.master_factor = new_mfact; |
715 |
monitor.master_factor = new_mfact; |
|
|
716 |
+ if let Some(ref mut pertag) = monitor.pertag { |
|
|
717 |
+ pertag.master_factors[pertag.current_tag] = new_mfact; |
|
|
718 |
+ } |
| 713 |
self.apply_layout()?; |
719 |
self.apply_layout()?; |
| 714 |
} |
720 |
} |
| 715 |
Ok(()) |
721 |
Ok(()) |
| @@ -719,11 +725,27 @@ impl WindowManager { |
| 719 |
if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
725 |
if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
| 720 |
let new_nmaster = (monitor.num_master + delta).max(0); |
726 |
let new_nmaster = (monitor.num_master + delta).max(0); |
| 721 |
monitor.num_master = new_nmaster; |
727 |
monitor.num_master = new_nmaster; |
|
|
728 |
+ if let Some(ref mut pertag) = monitor.pertag { |
|
|
729 |
+ pertag.num_masters[pertag.current_tag] = new_nmaster; |
|
|
730 |
+ } |
| 722 |
self.apply_layout()?; |
731 |
self.apply_layout()?; |
| 723 |
} |
732 |
} |
| 724 |
Ok(()) |
733 |
Ok(()) |
| 725 |
} |
734 |
} |
| 726 |
|
735 |
|
|
|
736 |
+ fn toggle_bar(&mut self) -> WmResult<()> { |
|
|
737 |
+ if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
|
|
738 |
+ monitor.show_bar = !monitor.show_bar; |
|
|
739 |
+ self.show_bar = monitor.show_bar; |
|
|
740 |
+ if let Some(ref mut pertag) = monitor.pertag { |
|
|
741 |
+ pertag.show_bars[pertag.current_tag] = monitor.show_bar; |
|
|
742 |
+ } |
|
|
743 |
+ } |
|
|
744 |
+ self.apply_layout()?; |
|
|
745 |
+ self.update_bar()?; |
|
|
746 |
+ Ok(()) |
|
|
747 |
+ } |
|
|
748 |
+ |
| 727 |
fn get_layout_symbol(&self) -> String { |
749 |
fn get_layout_symbol(&self) -> String { |
| 728 |
let layout_name = self.layout.name(); |
750 |
let layout_name = self.layout.name(); |
| 729 |
self.config |
751 |
self.config |
| @@ -871,6 +893,11 @@ impl WindowManager { |
| 871 |
match layout_from_str(layout_name) { |
893 |
match layout_from_str(layout_name) { |
| 872 |
Ok(layout) => { |
894 |
Ok(layout) => { |
| 873 |
self.layout = layout; |
895 |
self.layout = layout; |
|
|
896 |
+ if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
|
|
897 |
+ if let Some(ref mut pertag) = monitor.pertag { |
|
|
898 |
+ pertag.layouts[pertag.current_tag] = layout_name.to_string(); |
|
|
899 |
+ } |
|
|
900 |
+ } |
| 874 |
if layout_name != "normie" && layout_name != "floating" { |
901 |
if layout_name != "normie" && layout_name != "floating" { |
| 875 |
self.floating_windows.clear(); |
902 |
self.floating_windows.clear(); |
| 876 |
} |
903 |
} |
| @@ -888,6 +915,11 @@ impl WindowManager { |
| 888 |
match layout_from_str(next_name) { |
915 |
match layout_from_str(next_name) { |
| 889 |
Ok(layout) => { |
916 |
Ok(layout) => { |
| 890 |
self.layout = layout; |
917 |
self.layout = layout; |
|
|
918 |
+ if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
|
|
919 |
+ if let Some(ref mut pertag) = monitor.pertag { |
|
|
920 |
+ pertag.layouts[pertag.current_tag] = next_name.to_string(); |
|
|
921 |
+ } |
|
|
922 |
+ } |
| 891 |
if next_name != "normie" && next_name != "floating" { |
923 |
if next_name != "normie" && next_name != "floating" { |
| 892 |
self.floating_windows.clear(); |
924 |
self.floating_windows.clear(); |
| 893 |
} |
925 |
} |
| @@ -1243,21 +1275,48 @@ impl WindowManager { |
| 1243 |
return Ok(()); |
1275 |
return Ok(()); |
| 1244 |
} |
1276 |
} |
| 1245 |
|
1277 |
|
| 1246 |
- let monitor = match self.monitors.get_mut(self.selected_monitor) { |
|
|
| 1247 |
- Some(m) => m, |
|
|
| 1248 |
- None => return Ok(()), |
|
|
| 1249 |
- }; |
|
|
| 1250 |
- |
|
|
| 1251 |
let new_tagset = tag_mask(tag_index); |
1278 |
let new_tagset = tag_mask(tag_index); |
|
|
1279 |
+ let mut layout_name: Option<String> = None; |
|
|
1280 |
+ let mut toggle_bar = false; |
| 1252 |
|
1281 |
|
| 1253 |
- if new_tagset == monitor.tagset[monitor.selected_tags_index] { |
1282 |
+ if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
| 1254 |
- if !self.config.tag_back_and_forth { |
1283 |
+ if new_tagset == monitor.tagset[monitor.selected_tags_index] { |
| 1255 |
- return Ok(()); |
1284 |
+ if !self.config.tag_back_and_forth { |
|
|
1285 |
+ return Ok(()); |
|
|
1286 |
+ } |
|
|
1287 |
+ monitor.tagset.swap(0, 1); |
|
|
1288 |
+ if let Some(ref mut pertag) = monitor.pertag { |
|
|
1289 |
+ let tmp = pertag.previous_tag; |
|
|
1290 |
+ pertag.previous_tag = pertag.current_tag; |
|
|
1291 |
+ pertag.current_tag = tmp; |
|
|
1292 |
+ } |
|
|
1293 |
+ } else { |
|
|
1294 |
+ monitor.selected_tags_index ^= 1; |
|
|
1295 |
+ monitor.tagset[monitor.selected_tags_index] = new_tagset; |
|
|
1296 |
+ if let Some(ref mut pertag) = monitor.pertag { |
|
|
1297 |
+ pertag.previous_tag = pertag.current_tag; |
|
|
1298 |
+ pertag.current_tag = tag_index + 1; |
|
|
1299 |
+ } |
| 1256 |
} |
1300 |
} |
| 1257 |
- monitor.tagset.swap(0, 1); |
1301 |
+ |
| 1258 |
- } else { |
1302 |
+ if let Some(ref pertag) = monitor.pertag { |
| 1259 |
- monitor.selected_tags_index ^= 1; |
1303 |
+ monitor.num_master = pertag.num_masters[pertag.current_tag]; |
| 1260 |
- monitor.tagset[monitor.selected_tags_index] = new_tagset; |
1304 |
+ monitor.master_factor = pertag.master_factors[pertag.current_tag]; |
|
|
1305 |
+ layout_name = Some(pertag.layouts[pertag.current_tag].clone()); |
|
|
1306 |
+ if monitor.show_bar != pertag.show_bars[pertag.current_tag] { |
|
|
1307 |
+ toggle_bar = true; |
|
|
1308 |
+ } |
|
|
1309 |
+ } |
|
|
1310 |
+ } |
|
|
1311 |
+ |
|
|
1312 |
+ if let Some(name) = layout_name { |
|
|
1313 |
+ if let Ok(layout) = layout_from_str(&name) { |
|
|
1314 |
+ self.layout = layout; |
|
|
1315 |
+ } |
|
|
1316 |
+ } |
|
|
1317 |
+ |
|
|
1318 |
+ if toggle_bar { |
|
|
1319 |
+ self.toggle_bar()?; |
| 1261 |
} |
1320 |
} |
| 1262 |
|
1321 |
|
| 1263 |
self.save_selected_tags()?; |
1322 |
self.save_selected_tags()?; |
| @@ -1273,19 +1332,50 @@ impl WindowManager { |
| 1273 |
return Ok(()); |
1332 |
return Ok(()); |
| 1274 |
} |
1333 |
} |
| 1275 |
|
1334 |
|
| 1276 |
- let monitor = match self.monitors.get_mut(self.selected_monitor) { |
1335 |
+ let num_tags = self.config.tags.len(); |
| 1277 |
- Some(m) => m, |
1336 |
+ let all_tags_mask = (1u32 << num_tags) - 1; |
| 1278 |
- None => return Ok(()), |
1337 |
+ let mut layout_name: Option<String> = None; |
| 1279 |
- }; |
1338 |
+ let mut toggle_bar = false; |
| 1280 |
|
1339 |
|
| 1281 |
- let mask = tag_mask(tag_index); |
1340 |
+ if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
| 1282 |
- let new_tagset = monitor.tagset[monitor.selected_tags_index] ^ mask; |
1341 |
+ let mask = tag_mask(tag_index); |
|
|
1342 |
+ let new_tagset = monitor.tagset[monitor.selected_tags_index] ^ mask; |
| 1283 |
|
1343 |
|
| 1284 |
- if new_tagset == 0 { |
1344 |
+ if new_tagset == 0 { |
| 1285 |
- return Ok(()); |
1345 |
+ return Ok(()); |
|
|
1346 |
+ } |
|
|
1347 |
+ |
|
|
1348 |
+ monitor.tagset[monitor.selected_tags_index] = new_tagset; |
|
|
1349 |
+ |
|
|
1350 |
+ if let Some(ref mut pertag) = monitor.pertag { |
|
|
1351 |
+ if new_tagset == all_tags_mask { |
|
|
1352 |
+ pertag.previous_tag = pertag.current_tag; |
|
|
1353 |
+ pertag.current_tag = 0; |
|
|
1354 |
+ } |
|
|
1355 |
+ |
|
|
1356 |
+ if pertag.current_tag > 0 && (new_tagset & (1 << (pertag.current_tag - 1))) == 0 { |
|
|
1357 |
+ pertag.previous_tag = pertag.current_tag; |
|
|
1358 |
+ pertag.current_tag = (new_tagset.trailing_zeros() as usize) + 1; |
|
|
1359 |
+ } |
|
|
1360 |
+ |
|
|
1361 |
+ monitor.num_master = pertag.num_masters[pertag.current_tag]; |
|
|
1362 |
+ monitor.master_factor = pertag.master_factors[pertag.current_tag]; |
|
|
1363 |
+ layout_name = Some(pertag.layouts[pertag.current_tag].clone()); |
|
|
1364 |
+ if monitor.show_bar != pertag.show_bars[pertag.current_tag] { |
|
|
1365 |
+ toggle_bar = true; |
|
|
1366 |
+ } |
|
|
1367 |
+ } |
| 1286 |
} |
1368 |
} |
| 1287 |
|
1369 |
|
| 1288 |
- monitor.tagset[monitor.selected_tags_index] = new_tagset; |
1370 |
+ if let Some(name) = layout_name { |
|
|
1371 |
+ if let Ok(layout) = layout_from_str(&name) { |
|
|
1372 |
+ self.layout = layout; |
|
|
1373 |
+ } |
|
|
1374 |
+ } |
|
|
1375 |
+ |
|
|
1376 |
+ if toggle_bar { |
|
|
1377 |
+ self.toggle_bar()?; |
|
|
1378 |
+ } |
| 1289 |
|
1379 |
|
| 1290 |
self.save_selected_tags()?; |
1380 |
self.save_selected_tags()?; |
| 1291 |
self.focus(None)?; |
1381 |
self.focus(None)?; |