| @@ -16,7 +16,6 @@ use x11rb::protocol::Event; |
| 16 |
use x11rb::protocol::xproto::*; |
16 |
use x11rb::protocol::xproto::*; |
| 17 |
use x11rb::rust_connection::RustConnection; |
17 |
use x11rb::rust_connection::RustConnection; |
| 18 |
|
18 |
|
| 19 |
- |
|
|
| 20 |
pub fn tag_mask(tag: usize) -> TagMask { |
19 |
pub fn tag_mask(tag: usize) -> TagMask { |
| 21 |
1 << tag |
20 |
1 << tag |
| 22 |
} |
21 |
} |
| @@ -82,9 +81,15 @@ impl AtomCache { |
| 82 |
.atom; |
81 |
.atom; |
| 83 |
|
82 |
|
| 84 |
let wm_name = AtomEnum::WM_NAME.into(); |
83 |
let wm_name = AtomEnum::WM_NAME.into(); |
| 85 |
- let net_wm_name = connection.intern_atom(false, b"_NET_WM_NAME")?.reply()?.atom; |
84 |
+ let net_wm_name = connection |
|
|
85 |
+ .intern_atom(false, b"_NET_WM_NAME")? |
|
|
86 |
+ .reply()? |
|
|
87 |
+ .atom; |
| 86 |
let utf8_string = connection.intern_atom(false, b"UTF8_STRING")?.reply()?.atom; |
88 |
let utf8_string = connection.intern_atom(false, b"UTF8_STRING")?.reply()?.atom; |
| 87 |
- let net_active_window = connection.intern_atom(false, b"_NET_ACTIVE_WINDOW")?.reply()?.atom; |
89 |
+ let net_active_window = connection |
|
|
90 |
+ .intern_atom(false, b"_NET_ACTIVE_WINDOW")? |
|
|
91 |
+ .reply()? |
|
|
92 |
+ .atom; |
| 88 |
|
93 |
|
| 89 |
Ok(Self { |
94 |
Ok(Self { |
| 90 |
net_current_desktop, |
95 |
net_current_desktop, |
| @@ -238,7 +243,9 @@ impl WindowManager { |
| 238 |
&font, |
243 |
&font, |
| 239 |
(monitor.screen_x + config.gap_outer_horizontal as i32) as i16, |
244 |
(monitor.screen_x + config.gap_outer_horizontal as i32) as i16, |
| 240 |
(monitor.screen_y as f32 + bar_height + config.gap_outer_vertical as f32) as i16, |
245 |
(monitor.screen_y as f32 + bar_height + config.gap_outer_vertical as f32) as i16, |
| 241 |
- monitor.screen_width.saturating_sub(2 * config.gap_outer_horizontal as i32) as u16, |
246 |
+ monitor |
|
|
247 |
+ .screen_width |
|
|
248 |
+ .saturating_sub(2 * config.gap_outer_horizontal as i32) as u16, |
| 242 |
config.scheme_occupied, |
249 |
config.scheme_occupied, |
| 243 |
config.scheme_selected, |
250 |
config.scheme_selected, |
| 244 |
)?; |
251 |
)?; |
| @@ -542,7 +549,13 @@ impl WindowManager { |
| 542 |
} |
549 |
} |
| 543 |
|
550 |
|
| 544 |
let (is_fixed, x, y, w, h) = if let Some(client) = self.clients.get(&focused) { |
551 |
let (is_fixed, x, y, w, h) = if let Some(client) = self.clients.get(&focused) { |
| 545 |
- (client.is_fixed, client.x_position as i32, client.y_position as i32, client.width as u32, client.height as u32) |
552 |
+ ( |
|
|
553 |
+ client.is_fixed, |
|
|
554 |
+ client.x_position as i32, |
|
|
555 |
+ client.y_position as i32, |
|
|
556 |
+ client.width as u32, |
|
|
557 |
+ client.height as u32, |
|
|
558 |
+ ) |
| 546 |
} else { |
559 |
} else { |
| 547 |
return Ok(()); |
560 |
return Ok(()); |
| 548 |
}; |
561 |
}; |
| @@ -593,7 +606,6 @@ impl WindowManager { |
| 593 |
Ok(()) |
606 |
Ok(()) |
| 594 |
} |
607 |
} |
| 595 |
|
608 |
|
| 596 |
- |
|
|
| 597 |
fn get_layout_symbol(&self) -> String { |
609 |
fn get_layout_symbol(&self) -> String { |
| 598 |
let layout_name = self.layout.name(); |
610 |
let layout_name = self.layout.name(); |
| 599 |
self.config |
611 |
self.config |
| @@ -647,7 +659,6 @@ impl WindowManager { |
| 647 |
} |
659 |
} |
| 648 |
} |
660 |
} |
| 649 |
|
661 |
|
| 650 |
- |
|
|
| 651 |
fn update_bar(&mut self) -> WmResult<()> { |
662 |
fn update_bar(&mut self) -> WmResult<()> { |
| 652 |
let layout_symbol = self.get_layout_symbol(); |
663 |
let layout_symbol = self.get_layout_symbol(); |
| 653 |
let keychord_indicator = self.get_keychord_indicator(); |
664 |
let keychord_indicator = self.get_keychord_indicator(); |
| @@ -844,11 +855,12 @@ impl WindowManager { |
| 844 |
Ok(()) |
855 |
Ok(()) |
| 845 |
} |
856 |
} |
| 846 |
|
857 |
|
| 847 |
- |
|
|
| 848 |
fn is_window_visible(&self, window: Window) -> bool { |
858 |
fn is_window_visible(&self, window: Window) -> bool { |
| 849 |
if let Some(client) = self.clients.get(&window) { |
859 |
if let Some(client) = self.clients.get(&window) { |
| 850 |
let monitor = self.monitors.get(client.monitor_index); |
860 |
let monitor = self.monitors.get(client.monitor_index); |
| 851 |
- let selected_tags = monitor.map(|m| m.tagset[m.selected_tags_index]).unwrap_or(0); |
861 |
+ let selected_tags = monitor |
|
|
862 |
+ .map(|m| m.tagset[m.selected_tags_index]) |
|
|
863 |
+ .unwrap_or(0); |
| 852 |
(client.tags & selected_tags) != 0 |
864 |
(client.tags & selected_tags) != 0 |
| 853 |
} else { |
865 |
} else { |
| 854 |
false |
866 |
false |
| @@ -904,8 +916,14 @@ impl WindowManager { |
| 904 |
let mut max_area = 0; |
916 |
let mut max_area = 0; |
| 905 |
|
917 |
|
| 906 |
for (idx, monitor) in self.monitors.iter().enumerate() { |
918 |
for (idx, monitor) in self.monitors.iter().enumerate() { |
| 907 |
- let intersect_width = 0.max((x + w).min(monitor.window_area_x + monitor.window_area_width) - x.max(monitor.window_area_x)); |
919 |
+ let intersect_width = 0.max( |
| 908 |
- let intersect_height = 0.max((y + h).min(monitor.window_area_y + monitor.window_area_height) - y.max(monitor.window_area_y)); |
920 |
+ (x + w).min(monitor.window_area_x + monitor.window_area_width) |
|
|
921 |
+ - x.max(monitor.window_area_x), |
|
|
922 |
+ ); |
|
|
923 |
+ let intersect_height = 0.max( |
|
|
924 |
+ (y + h).min(monitor.window_area_y + monitor.window_area_height) |
|
|
925 |
+ - y.max(monitor.window_area_y), |
|
|
926 |
+ ); |
| 909 |
let area = intersect_width * intersect_height; |
927 |
let area = intersect_width * intersect_height; |
| 910 |
|
928 |
|
| 911 |
if area > max_area { |
929 |
if area > max_area { |
| @@ -917,10 +935,12 @@ impl WindowManager { |
| 917 |
best_monitor |
935 |
best_monitor |
| 918 |
} |
936 |
} |
| 919 |
|
937 |
|
| 920 |
- fn move_window_to_monitor(&mut self, window: Window, target_monitor_index: usize) -> WmResult<()> { |
938 |
+ fn move_window_to_monitor( |
| 921 |
- let current_monitor_index = self.clients |
939 |
+ &mut self, |
| 922 |
- .get(&window) |
940 |
+ window: Window, |
| 923 |
- .map(|c| c.monitor_index); |
941 |
+ target_monitor_index: usize, |
|
|
942 |
+ ) -> WmResult<()> { |
|
|
943 |
+ let current_monitor_index = self.clients.get(&window).map(|c| c.monitor_index); |
| 924 |
|
944 |
|
| 925 |
if let Some(current_idx) = current_monitor_index { |
945 |
if let Some(current_idx) = current_monitor_index { |
| 926 |
if current_idx == target_monitor_index { |
946 |
if current_idx == target_monitor_index { |
| @@ -1078,7 +1098,7 @@ impl WindowManager { |
| 1078 |
|
1098 |
|
| 1079 |
self.save_selected_tags()?; |
1099 |
self.save_selected_tags()?; |
| 1080 |
self.focus(None)?; |
1100 |
self.focus(None)?; |
| 1081 |
- self.apply_layout()?; |
1101 |
+ self.apply_layout()?; |
| 1082 |
self.update_bar()?; |
1102 |
self.update_bar()?; |
| 1083 |
|
1103 |
|
| 1084 |
Ok(()) |
1104 |
Ok(()) |
| @@ -1262,7 +1282,10 @@ impl WindowManager { |
| 1262 |
if self.send_event(window, self.atoms.wm_delete_window)? { |
1282 |
if self.send_event(window, self.atoms.wm_delete_window)? { |
| 1263 |
self.connection.flush()?; |
1283 |
self.connection.flush()?; |
| 1264 |
} else { |
1284 |
} else { |
| 1265 |
- eprintln!("Window {} doesn't support WM_DELETE_WINDOW, killing forcefully", window); |
1285 |
+ eprintln!( |
|
|
1286 |
+ "Window {} doesn't support WM_DELETE_WINDOW, killing forcefully", |
|
|
1287 |
+ window |
|
|
1288 |
+ ); |
| 1266 |
self.connection.kill_client(window)?; |
1289 |
self.connection.kill_client(window)?; |
| 1267 |
self.connection.flush()?; |
1290 |
self.connection.flush()?; |
| 1268 |
} |
1291 |
} |
| @@ -1270,14 +1293,17 @@ impl WindowManager { |
| 1270 |
} |
1293 |
} |
| 1271 |
|
1294 |
|
| 1272 |
fn send_event(&self, window: Window, protocol: Atom) -> WmResult<bool> { |
1295 |
fn send_event(&self, window: Window, protocol: Atom) -> WmResult<bool> { |
| 1273 |
- let protocols_reply = self.connection.get_property( |
1296 |
+ let protocols_reply = self |
| 1274 |
- false, |
1297 |
+ .connection |
| 1275 |
- window, |
1298 |
+ .get_property( |
| 1276 |
- self.atoms.wm_protocols, |
1299 |
+ false, |
| 1277 |
- AtomEnum::ATOM, |
1300 |
+ window, |
| 1278 |
- 0, |
1301 |
+ self.atoms.wm_protocols, |
| 1279 |
- 100, |
1302 |
+ AtomEnum::ATOM, |
| 1280 |
- )?.reply(); |
1303 |
+ 0, |
|
|
1304 |
+ 100, |
|
|
1305 |
+ )? |
|
|
1306 |
+ .reply(); |
| 1281 |
|
1307 |
|
| 1282 |
let protocols_reply = match protocols_reply { |
1308 |
let protocols_reply = match protocols_reply { |
| 1283 |
Ok(reply) => reply, |
1309 |
Ok(reply) => reply, |
| @@ -1300,15 +1326,17 @@ impl WindowManager { |
| 1300 |
sequence: 0, |
1326 |
sequence: 0, |
| 1301 |
window, |
1327 |
window, |
| 1302 |
type_: self.atoms.wm_protocols, |
1328 |
type_: self.atoms.wm_protocols, |
| 1303 |
- data: x11rb::protocol::xproto::ClientMessageData::from([protocol, x11rb::CURRENT_TIME, 0, 0, 0]), |
1329 |
+ data: x11rb::protocol::xproto::ClientMessageData::from([ |
|
|
1330 |
+ protocol, |
|
|
1331 |
+ x11rb::CURRENT_TIME, |
|
|
1332 |
+ 0, |
|
|
1333 |
+ 0, |
|
|
1334 |
+ 0, |
|
|
1335 |
+ ]), |
| 1304 |
}; |
1336 |
}; |
| 1305 |
|
1337 |
|
| 1306 |
- self.connection.send_event( |
1338 |
+ self.connection |
| 1307 |
- false, |
1339 |
+ .send_event(false, window, EventMask::NO_EVENT, event)?; |
| 1308 |
- window, |
|
|
| 1309 |
- EventMask::NO_EVENT, |
|
|
| 1310 |
- event, |
|
|
| 1311 |
- )?; |
|
|
| 1312 |
self.connection.flush()?; |
1340 |
self.connection.flush()?; |
| 1313 |
Ok(true) |
1341 |
Ok(true) |
| 1314 |
} |
1342 |
} |
| @@ -1318,14 +1346,10 @@ impl WindowManager { |
| 1318 |
client.is_urgent = urgent; |
1346 |
client.is_urgent = urgent; |
| 1319 |
} |
1347 |
} |
| 1320 |
|
1348 |
|
| 1321 |
- let hints_reply = self.connection.get_property( |
1349 |
+ let hints_reply = self |
| 1322 |
- false, |
1350 |
+ .connection |
| 1323 |
- window, |
1351 |
+ .get_property(false, window, AtomEnum::WM_HINTS, AtomEnum::WM_HINTS, 0, 9)? |
| 1324 |
- AtomEnum::WM_HINTS, |
1352 |
+ .reply(); |
| 1325 |
- AtomEnum::WM_HINTS, |
|
|
| 1326 |
- 0, |
|
|
| 1327 |
- 9, |
|
|
| 1328 |
- )?.reply(); |
|
|
| 1329 |
|
1353 |
|
| 1330 |
if let Ok(hints) = hints_reply { |
1354 |
if let Ok(hints) = hints_reply { |
| 1331 |
if hints.value.len() >= 4 { |
1355 |
if hints.value.len() >= 4 { |
| @@ -1361,14 +1385,10 @@ impl WindowManager { |
| 1361 |
} |
1385 |
} |
| 1362 |
|
1386 |
|
| 1363 |
fn get_window_atom_property(&self, window: Window, property: Atom) -> WmResult<Option<Atom>> { |
1387 |
fn get_window_atom_property(&self, window: Window, property: Atom) -> WmResult<Option<Atom>> { |
| 1364 |
- let reply = self.connection.get_property( |
1388 |
+ let reply = self |
| 1365 |
- false, |
1389 |
+ .connection |
| 1366 |
- window, |
1390 |
+ .get_property(false, window, property, AtomEnum::ATOM, 0, 1)? |
| 1367 |
- property, |
1391 |
+ .reply(); |
| 1368 |
- AtomEnum::ATOM, |
|
|
| 1369 |
- 0, |
|
|
| 1370 |
- 1, |
|
|
| 1371 |
- )?.reply(); |
|
|
| 1372 |
|
1392 |
|
| 1373 |
match reply { |
1393 |
match reply { |
| 1374 |
Ok(prop) if !prop.value.is_empty() && prop.value.len() >= 4 => { |
1394 |
Ok(prop) if !prop.value.is_empty() && prop.value.len() >= 4 => { |
| @@ -1386,18 +1406,26 @@ impl WindowManager { |
| 1386 |
|
1406 |
|
| 1387 |
fn fullscreen(&mut self) -> WmResult<()> { |
1407 |
fn fullscreen(&mut self) -> WmResult<()> { |
| 1388 |
if self.show_bar { |
1408 |
if self.show_bar { |
| 1389 |
- let windows: Vec<Window> = self.windows.iter() |
1409 |
+ let windows: Vec<Window> = self |
|
|
1410 |
+ .windows |
|
|
1411 |
+ .iter() |
| 1390 |
.filter(|&&w| self.is_window_visible(w)) |
1412 |
.filter(|&&w| self.is_window_visible(w)) |
| 1391 |
.copied() |
1413 |
.copied() |
| 1392 |
.collect(); |
1414 |
.collect(); |
| 1393 |
|
1415 |
|
| 1394 |
for window in &windows { |
1416 |
for window in &windows { |
| 1395 |
if let Ok(geom) = self.connection.get_geometry(*window)?.reply() { |
1417 |
if let Ok(geom) = self.connection.get_geometry(*window)?.reply() { |
| 1396 |
- self.floating_geometry_before_fullscreen.insert( |
1418 |
+ self.floating_geometry_before_fullscreen.insert( |
| 1397 |
- *window, |
1419 |
+ *window, |
| 1398 |
- (geom.x, geom.y, geom.width, geom.height, geom.border_width as u16), |
1420 |
+ ( |
| 1399 |
- ); |
1421 |
+ geom.x, |
| 1400 |
- } |
1422 |
+ geom.y, |
|
|
1423 |
+ geom.width, |
|
|
1424 |
+ geom.height, |
|
|
1425 |
+ geom.border_width as u16, |
|
|
1426 |
+ ), |
|
|
1427 |
+ ); |
|
|
1428 |
+ } |
| 1401 |
} |
1429 |
} |
| 1402 |
|
1430 |
|
| 1403 |
self.last_layout = Some(self.layout.name()); |
1431 |
self.last_layout = Some(self.layout.name()); |
| @@ -1408,13 +1436,16 @@ impl WindowManager { |
| 1408 |
self.apply_layout()?; |
1436 |
self.apply_layout()?; |
| 1409 |
|
1437 |
|
| 1410 |
let border_width = self.config.border_width; |
1438 |
let border_width = self.config.border_width; |
| 1411 |
- let floating_windows: Vec<Window> = windows.iter() |
1439 |
+ let floating_windows: Vec<Window> = windows |
|
|
1440 |
+ .iter() |
| 1412 |
.filter(|&&w| self.floating_windows.contains(&w)) |
1441 |
.filter(|&&w| self.floating_windows.contains(&w)) |
| 1413 |
.copied() |
1442 |
.copied() |
| 1414 |
.collect(); |
1443 |
.collect(); |
| 1415 |
|
1444 |
|
| 1416 |
for window in floating_windows { |
1445 |
for window in floating_windows { |
| 1417 |
- let monitor_idx = self.clients.get(&window) |
1446 |
+ let monitor_idx = self |
|
|
1447 |
+ .clients |
|
|
1448 |
+ .get(&window) |
| 1418 |
.map(|c| c.monitor_index) |
1449 |
.map(|c| c.monitor_index) |
| 1419 |
.unwrap_or(self.selected_monitor); |
1450 |
.unwrap_or(self.selected_monitor); |
| 1420 |
let monitor = &self.monitors[monitor_idx]; |
1451 |
let monitor = &self.monitors[monitor_idx]; |
| @@ -1430,8 +1461,14 @@ impl WindowManager { |
| 1430 |
|
1461 |
|
| 1431 |
let window_x = monitor.screen_x + outer_gap_h as i32; |
1462 |
let window_x = monitor.screen_x + outer_gap_h as i32; |
| 1432 |
let window_y = monitor.screen_y + outer_gap_v as i32; |
1463 |
let window_y = monitor.screen_y + outer_gap_v as i32; |
| 1433 |
- let window_width = monitor.screen_width.saturating_sub(2 * outer_gap_h as i32).saturating_sub(2 * border_width as i32); |
1464 |
+ let window_width = monitor |
| 1434 |
- let window_height = monitor.screen_height.saturating_sub(2 * outer_gap_v as i32).saturating_sub(2 * border_width as i32); |
1465 |
+ .screen_width |
|
|
1466 |
+ .saturating_sub(2 * outer_gap_h as i32) |
|
|
1467 |
+ .saturating_sub(2 * border_width as i32); |
|
|
1468 |
+ let window_height = monitor |
|
|
1469 |
+ .screen_height |
|
|
1470 |
+ .saturating_sub(2 * outer_gap_v as i32) |
|
|
1471 |
+ .saturating_sub(2 * border_width as i32); |
| 1435 |
|
1472 |
|
| 1436 |
self.connection.configure_window( |
1473 |
self.connection.configure_window( |
| 1437 |
window, |
1474 |
window, |
| @@ -1450,13 +1487,16 @@ impl WindowManager { |
| 1450 |
} |
1487 |
} |
| 1451 |
} |
1488 |
} |
| 1452 |
|
1489 |
|
| 1453 |
- let windows_to_restore: Vec<Window> = self.floating_geometry_before_fullscreen |
1490 |
+ let windows_to_restore: Vec<Window> = self |
|
|
1491 |
+ .floating_geometry_before_fullscreen |
| 1454 |
.keys() |
1492 |
.keys() |
| 1455 |
.copied() |
1493 |
.copied() |
| 1456 |
.collect(); |
1494 |
.collect(); |
| 1457 |
|
1495 |
|
| 1458 |
for window in windows_to_restore { |
1496 |
for window in windows_to_restore { |
| 1459 |
- if let Some(&(x, y, width, height, border_width)) = self.floating_geometry_before_fullscreen.get(&window) { |
1497 |
+ if let Some(&(x, y, width, height, border_width)) = |
|
|
1498 |
+ self.floating_geometry_before_fullscreen.get(&window) |
|
|
1499 |
+ { |
| 1460 |
self.connection.configure_window( |
1500 |
self.connection.configure_window( |
| 1461 |
window, |
1501 |
window, |
| 1462 |
&ConfigureWindowAux::new() |
1502 |
&ConfigureWindowAux::new() |
| @@ -1499,7 +1539,9 @@ impl WindowManager { |
| 1499 |
} |
1539 |
} |
| 1500 |
|
1540 |
|
| 1501 |
fn set_window_fullscreen(&mut self, window: Window, fullscreen: bool) -> WmResult<()> { |
1541 |
fn set_window_fullscreen(&mut self, window: Window, fullscreen: bool) -> WmResult<()> { |
| 1502 |
- let monitor_idx = self.clients.get(&window) |
1542 |
+ let monitor_idx = self |
|
|
1543 |
+ .clients |
|
|
1544 |
+ .get(&window) |
| 1503 |
.map(|c| c.monitor_index) |
1545 |
.map(|c| c.monitor_index) |
| 1504 |
.unwrap_or(self.selected_monitor); |
1546 |
.unwrap_or(self.selected_monitor); |
| 1505 |
let monitor = &self.monitors[monitor_idx]; |
1547 |
let monitor = &self.monitors[monitor_idx]; |
| @@ -1622,7 +1664,8 @@ impl WindowManager { |
| 1622 |
} |
1664 |
} |
| 1623 |
|
1665 |
|
| 1624 |
fn get_window_class_instance(&self, window: Window) -> (String, String) { |
1666 |
fn get_window_class_instance(&self, window: Window) -> (String, String) { |
| 1625 |
- let reply = self.connection |
1667 |
+ let reply = self |
|
|
1668 |
+ .connection |
| 1626 |
.get_property(false, window, AtomEnum::WM_CLASS, AtomEnum::STRING, 0, 1024) |
1669 |
.get_property(false, window, AtomEnum::WM_CLASS, AtomEnum::STRING, 0, 1024) |
| 1627 |
.ok() |
1670 |
.ok() |
| 1628 |
.and_then(|cookie| cookie.reply().ok()); |
1671 |
.and_then(|cookie| cookie.reply().ok()); |
| @@ -1643,7 +1686,11 @@ impl WindowManager { |
| 1643 |
|
1686 |
|
| 1644 |
fn apply_rules(&mut self, window: Window) -> WmResult<()> { |
1687 |
fn apply_rules(&mut self, window: Window) -> WmResult<()> { |
| 1645 |
let (instance, class) = self.get_window_class_instance(window); |
1688 |
let (instance, class) = self.get_window_class_instance(window); |
| 1646 |
- let title = self.clients.get(&window).map(|c| c.name.clone()).unwrap_or_default(); |
1689 |
+ let title = self |
|
|
1690 |
+ .clients |
|
|
1691 |
+ .get(&window) |
|
|
1692 |
+ .map(|c| c.name.clone()) |
|
|
1693 |
+ .unwrap_or_default(); |
| 1647 |
|
1694 |
|
| 1648 |
let mut rule_tags: Option<u32> = None; |
1695 |
let mut rule_tags: Option<u32> = None; |
| 1649 |
let mut rule_floating: Option<bool> = None; |
1696 |
let mut rule_floating: Option<bool> = None; |
| @@ -1703,13 +1750,17 @@ impl WindowManager { |
| 1703 |
if let Some(parent_client) = self.clients.get(&parent) { |
1750 |
if let Some(parent_client) = self.clients.get(&parent) { |
| 1704 |
(parent_client.monitor_index, parent_client.tags) |
1751 |
(parent_client.monitor_index, parent_client.tags) |
| 1705 |
} else { |
1752 |
} else { |
| 1706 |
- let tags = self.monitors.get(self.selected_monitor) |
1753 |
+ let tags = self |
|
|
1754 |
+ .monitors |
|
|
1755 |
+ .get(self.selected_monitor) |
| 1707 |
.map(|m| m.tagset[m.selected_tags_index]) |
1756 |
.map(|m| m.tagset[m.selected_tags_index]) |
| 1708 |
.unwrap_or(tag_mask(0)); |
1757 |
.unwrap_or(tag_mask(0)); |
| 1709 |
(self.selected_monitor, tags) |
1758 |
(self.selected_monitor, tags) |
| 1710 |
} |
1759 |
} |
| 1711 |
} else { |
1760 |
} else { |
| 1712 |
- let tags = self.monitors.get(self.selected_monitor) |
1761 |
+ let tags = self |
|
|
1762 |
+ .monitors |
|
|
1763 |
+ .get(self.selected_monitor) |
| 1713 |
.map(|m| m.tagset[m.selected_tags_index]) |
1764 |
.map(|m| m.tagset[m.selected_tags_index]) |
| 1714 |
.unwrap_or(tag_mask(0)); |
1765 |
.unwrap_or(tag_mask(0)); |
| 1715 |
(self.selected_monitor, tags) |
1766 |
(self.selected_monitor, tags) |
| @@ -1734,13 +1785,33 @@ impl WindowManager { |
| 1734 |
self.apply_rules(window)?; |
1785 |
self.apply_rules(window)?; |
| 1735 |
} |
1786 |
} |
| 1736 |
|
1787 |
|
| 1737 |
- let client_monitor = self.clients.get(&window).map(|c| c.monitor_index).unwrap_or(monitor_index); |
1788 |
+ let client_monitor = self |
|
|
1789 |
+ .clients |
|
|
1790 |
+ .get(&window) |
|
|
1791 |
+ .map(|c| c.monitor_index) |
|
|
1792 |
+ .unwrap_or(monitor_index); |
| 1738 |
let monitor = &self.monitors[client_monitor]; |
1793 |
let monitor = &self.monitors[client_monitor]; |
| 1739 |
|
1794 |
|
| 1740 |
- let mut x = self.clients.get(&window).map(|c| c.x_position as i32).unwrap_or(0); |
1795 |
+ let mut x = self |
| 1741 |
- let mut y = self.clients.get(&window).map(|c| c.y_position as i32).unwrap_or(0); |
1796 |
+ .clients |
| 1742 |
- let w = self.clients.get(&window).map(|c| c.width as i32).unwrap_or(1); |
1797 |
+ .get(&window) |
| 1743 |
- let h = self.clients.get(&window).map(|c| c.height as i32).unwrap_or(1); |
1798 |
+ .map(|c| c.x_position as i32) |
|
|
1799 |
+ .unwrap_or(0); |
|
|
1800 |
+ let mut y = self |
|
|
1801 |
+ .clients |
|
|
1802 |
+ .get(&window) |
|
|
1803 |
+ .map(|c| c.y_position as i32) |
|
|
1804 |
+ .unwrap_or(0); |
|
|
1805 |
+ let w = self |
|
|
1806 |
+ .clients |
|
|
1807 |
+ .get(&window) |
|
|
1808 |
+ .map(|c| c.width as i32) |
|
|
1809 |
+ .unwrap_or(1); |
|
|
1810 |
+ let h = self |
|
|
1811 |
+ .clients |
|
|
1812 |
+ .get(&window) |
|
|
1813 |
+ .map(|c| c.height as i32) |
|
|
1814 |
+ .unwrap_or(1); |
| 1744 |
let bw = border_width as i32; |
1815 |
let bw = border_width as i32; |
| 1745 |
|
1816 |
|
| 1746 |
if x + w + 2 * bw > monitor.window_area_x + monitor.window_area_width { |
1817 |
if x + w + 2 * bw > monitor.window_area_x + monitor.window_area_width { |
| @@ -1773,11 +1844,18 @@ impl WindowManager { |
| 1773 |
self.connection.change_window_attributes( |
1844 |
self.connection.change_window_attributes( |
| 1774 |
window, |
1845 |
window, |
| 1775 |
&ChangeWindowAttributesAux::new().event_mask( |
1846 |
&ChangeWindowAttributesAux::new().event_mask( |
| 1776 |
- EventMask::ENTER_WINDOW | EventMask::FOCUS_CHANGE | EventMask::PROPERTY_CHANGE | EventMask::STRUCTURE_NOTIFY |
1847 |
+ EventMask::ENTER_WINDOW |
|
|
1848 |
+ | EventMask::FOCUS_CHANGE |
|
|
1849 |
+ | EventMask::PROPERTY_CHANGE |
|
|
1850 |
+ | EventMask::STRUCTURE_NOTIFY, |
| 1777 |
), |
1851 |
), |
| 1778 |
)?; |
1852 |
)?; |
| 1779 |
|
1853 |
|
| 1780 |
- let is_fixed = self.clients.get(&window).map(|c| c.is_fixed).unwrap_or(false); |
1854 |
+ let is_fixed = self |
|
|
1855 |
+ .clients |
|
|
1856 |
+ .get(&window) |
|
|
1857 |
+ .map(|c| c.is_fixed) |
|
|
1858 |
+ .unwrap_or(false); |
| 1781 |
if let Some(c) = self.clients.get_mut(&window) { |
1859 |
if let Some(c) = self.clients.get_mut(&window) { |
| 1782 |
if !c.is_floating { |
1860 |
if !c.is_floating { |
| 1783 |
c.is_floating = is_transient || is_fixed; |
1861 |
c.is_floating = is_transient || is_fixed; |
| @@ -1785,7 +1863,12 @@ impl WindowManager { |
| 1785 |
} |
1863 |
} |
| 1786 |
} |
1864 |
} |
| 1787 |
|
1865 |
|
| 1788 |
- if self.clients.get(&window).map(|c| c.is_floating).unwrap_or(false) { |
1866 |
+ if self |
|
|
1867 |
+ .clients |
|
|
1868 |
+ .get(&window) |
|
|
1869 |
+ .map(|c| c.is_floating) |
|
|
1870 |
+ .unwrap_or(false) |
|
|
1871 |
+ { |
| 1789 |
self.floating_windows.insert(window); |
1872 |
self.floating_windows.insert(window); |
| 1790 |
self.connection.configure_window( |
1873 |
self.connection.configure_window( |
| 1791 |
window, |
1874 |
window, |
| @@ -1813,7 +1896,11 @@ impl WindowManager { |
| 1813 |
let _ = self.save_client_tag(window, final_tags); |
1896 |
let _ = self.save_client_tag(window, final_tags); |
| 1814 |
|
1897 |
|
| 1815 |
if client_monitor == self.selected_monitor { |
1898 |
if client_monitor == self.selected_monitor { |
| 1816 |
- if let Some(old_sel) = self.monitors.get(self.selected_monitor).and_then(|m| m.selected_client) { |
1899 |
+ if let Some(old_sel) = self |
|
|
1900 |
+ .monitors |
|
|
1901 |
+ .get(self.selected_monitor) |
|
|
1902 |
+ .and_then(|m| m.selected_client) |
|
|
1903 |
+ { |
| 1817 |
self.unfocus(old_sel)?; |
1904 |
self.unfocus(old_sel)?; |
| 1818 |
} |
1905 |
} |
| 1819 |
} |
1906 |
} |
| @@ -1892,7 +1979,9 @@ impl WindowManager { |
| 1892 |
|
1979 |
|
| 1893 |
let mut win = window; |
1980 |
let mut win = window; |
| 1894 |
if win.is_none() || !self.is_visible(win.unwrap()) { |
1981 |
if win.is_none() || !self.is_visible(win.unwrap()) { |
| 1895 |
- let mut current = self.monitors.get(self.selected_monitor) |
1982 |
+ let mut current = self |
|
|
1983 |
+ .monitors |
|
|
1984 |
+ .get(self.selected_monitor) |
| 1896 |
.and_then(|m| m.stack_head); |
1985 |
.and_then(|m| m.stack_head); |
| 1897 |
|
1986 |
|
| 1898 |
while let Some(w) = current { |
1987 |
while let Some(w) = current { |
| @@ -1909,7 +1998,9 @@ impl WindowManager { |
| 1909 |
return Ok(()); |
1998 |
return Ok(()); |
| 1910 |
} |
1999 |
} |
| 1911 |
|
2000 |
|
| 1912 |
- let monitor_idx = self.clients.get(&win) |
2001 |
+ let monitor_idx = self |
|
|
2002 |
+ .clients |
|
|
2003 |
+ .get(&win) |
| 1913 |
.map(|c| c.monitor_index) |
2004 |
.map(|c| c.monitor_index) |
| 1914 |
.unwrap_or(self.selected_monitor); |
2005 |
.unwrap_or(self.selected_monitor); |
| 1915 |
if monitor_idx != self.selected_monitor { |
2006 |
if monitor_idx != self.selected_monitor { |
| @@ -1924,13 +2015,11 @@ impl WindowManager { |
| 1924 |
&ChangeWindowAttributesAux::new().border_pixel(self.config.border_focused), |
2015 |
&ChangeWindowAttributesAux::new().border_pixel(self.config.border_focused), |
| 1925 |
)?; |
2016 |
)?; |
| 1926 |
|
2017 |
|
| 1927 |
- self.connection.ungrab_button(ButtonIndex::ANY, win, ModMask::ANY)?; |
2018 |
+ self.connection |
|
|
2019 |
+ .ungrab_button(ButtonIndex::ANY, win, ModMask::ANY)?; |
| 1928 |
|
2020 |
|
| 1929 |
- self.connection.set_input_focus( |
2021 |
+ self.connection |
| 1930 |
- InputFocus::POINTER_ROOT, |
2022 |
+ .set_input_focus(InputFocus::POINTER_ROOT, win, x11rb::CURRENT_TIME)?; |
| 1931 |
- win, |
|
|
| 1932 |
- x11rb::CURRENT_TIME, |
|
|
| 1933 |
- )?; |
|
|
| 1934 |
|
2023 |
|
| 1935 |
if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
2024 |
if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
| 1936 |
monitor.selected_client = Some(win); |
2025 |
monitor.selected_client = Some(win); |
| @@ -2108,7 +2197,8 @@ impl WindowManager { |
| 2108 |
let mut current = monitor.clients_head; |
2197 |
let mut current = monitor.clients_head; |
| 2109 |
while let Some(window) = current { |
2198 |
while let Some(window) = current { |
| 2110 |
if let Some(client) = self.clients.get(&window) { |
2199 |
if let Some(client) = self.clients.get(&window) { |
| 2111 |
- let visible_tags = client.tags & monitor.tagset[monitor.selected_tags_index]; |
2200 |
+ let visible_tags = |
|
|
2201 |
+ client.tags & monitor.tagset[monitor.selected_tags_index]; |
| 2112 |
if visible_tags != 0 && !client.is_floating { |
2202 |
if visible_tags != 0 && !client.is_floating { |
| 2113 |
last = Some(window); |
2203 |
last = Some(window); |
| 2114 |
} |
2204 |
} |
| @@ -2205,7 +2295,8 @@ impl WindowManager { |
| 2205 |
_ => return Ok(()), |
2295 |
_ => return Ok(()), |
| 2206 |
}; |
2296 |
}; |
| 2207 |
|
2297 |
|
| 2208 |
- let old_selected = self.monitors |
2298 |
+ let old_selected = self |
|
|
2299 |
+ .monitors |
| 2209 |
.get(self.selected_monitor) |
2300 |
.get(self.selected_monitor) |
| 2210 |
.and_then(|m| m.selected_client); |
2301 |
.and_then(|m| m.selected_client); |
| 2211 |
|
2302 |
|
| @@ -2224,7 +2315,8 @@ impl WindowManager { |
| 2224 |
return Ok(()); |
2315 |
return Ok(()); |
| 2225 |
} |
2316 |
} |
| 2226 |
|
2317 |
|
| 2227 |
- let selected_window = self.monitors |
2318 |
+ let selected_window = self |
|
|
2319 |
+ .monitors |
| 2228 |
.get(self.selected_monitor) |
2320 |
.get(self.selected_monitor) |
| 2229 |
.and_then(|m| m.selected_client); |
2321 |
.and_then(|m| m.selected_client); |
| 2230 |
|
2322 |
|
| @@ -2277,7 +2369,8 @@ impl WindowManager { |
| 2277 |
} |
2369 |
} |
| 2278 |
|
2370 |
|
| 2279 |
fn drag_window(&mut self, window: Window) -> WmResult<()> { |
2371 |
fn drag_window(&mut self, window: Window) -> WmResult<()> { |
| 2280 |
- let is_fullscreen = self.clients |
2372 |
+ let is_fullscreen = self |
|
|
2373 |
+ .clients |
| 2281 |
.get(&window) |
2374 |
.get(&window) |
| 2282 |
.map(|c| c.is_fullscreen) |
2375 |
.map(|c| c.is_fullscreen) |
| 2283 |
.unwrap_or(false); |
2376 |
.unwrap_or(false); |
| @@ -2287,7 +2380,14 @@ impl WindowManager { |
| 2287 |
} |
2380 |
} |
| 2288 |
|
2381 |
|
| 2289 |
let client_info = self.clients.get(&window).map(|c| { |
2382 |
let client_info = self.clients.get(&window).map(|c| { |
| 2290 |
- (c.x_position, c.y_position, c.width, c.height, c.is_floating, c.monitor_index) |
2383 |
+ ( |
|
|
2384 |
+ c.x_position, |
|
|
2385 |
+ c.y_position, |
|
|
2386 |
+ c.width, |
|
|
2387 |
+ c.height, |
|
|
2388 |
+ c.is_floating, |
|
|
2389 |
+ c.monitor_index, |
|
|
2390 |
+ ) |
| 2291 |
}); |
2391 |
}); |
| 2292 |
|
2392 |
|
| 2293 |
let Some((orig_x, orig_y, width, height, was_floating, monitor_idx)) = client_info else { |
2393 |
let Some((orig_x, orig_y, width, height, was_floating, monitor_idx)) = client_info else { |
| @@ -2306,17 +2406,19 @@ impl WindowManager { |
| 2306 |
self.toggle_floating()?; |
2406 |
self.toggle_floating()?; |
| 2307 |
} |
2407 |
} |
| 2308 |
|
2408 |
|
| 2309 |
- self.connection.grab_pointer( |
2409 |
+ self.connection |
| 2310 |
- false, |
2410 |
+ .grab_pointer( |
| 2311 |
- self.root, |
2411 |
+ false, |
| 2312 |
- (EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE | |
2412 |
+ self.root, |
| 2313 |
- EventMask::BUTTON_PRESS).into(), |
2413 |
+ (EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE | EventMask::BUTTON_PRESS) |
| 2314 |
- GrabMode::ASYNC, |
2414 |
+ .into(), |
| 2315 |
- GrabMode::ASYNC, |
2415 |
+ GrabMode::ASYNC, |
| 2316 |
- x11rb::NONE, |
2416 |
+ GrabMode::ASYNC, |
| 2317 |
- x11rb::NONE, |
2417 |
+ x11rb::NONE, |
| 2318 |
- x11rb::CURRENT_TIME, |
2418 |
+ x11rb::NONE, |
| 2319 |
- )?.reply()?; |
2419 |
+ x11rb::CURRENT_TIME, |
|
|
2420 |
+ )? |
|
|
2421 |
+ .reply()?; |
| 2320 |
|
2422 |
|
| 2321 |
let pointer = self.connection.query_pointer(self.root)?.reply()?; |
2423 |
let pointer = self.connection.query_pointer(self.root)?.reply()?; |
| 2322 |
let (start_x, start_y) = (pointer.root_x as i32, pointer.root_y as i32); |
2424 |
let (start_x, start_y) = (pointer.root_x as i32, pointer.root_y as i32); |
| @@ -2338,20 +2440,30 @@ impl WindowManager { |
| 2338 |
|
2440 |
|
| 2339 |
if (monitor.window_area_x - new_x).abs() < snap { |
2441 |
if (monitor.window_area_x - new_x).abs() < snap { |
| 2340 |
new_x = monitor.window_area_x; |
2442 |
new_x = monitor.window_area_x; |
| 2341 |
- } else if ((monitor.window_area_x + monitor.window_area_width) - (new_x + width as i32)).abs() < snap { |
2443 |
+ } else if ((monitor.window_area_x + monitor.window_area_width) |
|
|
2444 |
+ - (new_x + width as i32)) |
|
|
2445 |
+ .abs() |
|
|
2446 |
+ < snap |
|
|
2447 |
+ { |
| 2342 |
new_x = monitor.window_area_x + monitor.window_area_width - width as i32; |
2448 |
new_x = monitor.window_area_x + monitor.window_area_width - width as i32; |
| 2343 |
} |
2449 |
} |
| 2344 |
|
2450 |
|
| 2345 |
if (monitor.window_area_y - new_y).abs() < snap { |
2451 |
if (monitor.window_area_y - new_y).abs() < snap { |
| 2346 |
new_y = monitor.window_area_y; |
2452 |
new_y = monitor.window_area_y; |
| 2347 |
- } else if ((monitor.window_area_y + monitor.window_area_height) - (new_y + height as i32)).abs() < snap { |
2453 |
+ } else if ((monitor.window_area_y + monitor.window_area_height) |
|
|
2454 |
+ - (new_y + height as i32)) |
|
|
2455 |
+ .abs() |
|
|
2456 |
+ < snap |
|
|
2457 |
+ { |
| 2348 |
new_y = monitor.window_area_y + monitor.window_area_height - height as i32; |
2458 |
new_y = monitor.window_area_y + monitor.window_area_height - height as i32; |
| 2349 |
} |
2459 |
} |
| 2350 |
|
2460 |
|
| 2351 |
- let should_resize = is_normie || self.clients |
2461 |
+ let should_resize = is_normie |
| 2352 |
- .get(&window) |
2462 |
+ || self |
| 2353 |
- .map(|c| c.is_floating) |
2463 |
+ .clients |
| 2354 |
- .unwrap_or(false); |
2464 |
+ .get(&window) |
|
|
2465 |
+ .map(|c| c.is_floating) |
|
|
2466 |
+ .unwrap_or(false); |
| 2355 |
|
2467 |
|
| 2356 |
if should_resize { |
2468 |
if should_resize { |
| 2357 |
if let Some(client) = self.clients.get_mut(&window) { |
2469 |
if let Some(client) = self.clients.get_mut(&window) { |
| @@ -2361,9 +2473,7 @@ impl WindowManager { |
| 2361 |
|
2473 |
|
| 2362 |
self.connection.configure_window( |
2474 |
self.connection.configure_window( |
| 2363 |
window, |
2475 |
window, |
| 2364 |
- &ConfigureWindowAux::new() |
2476 |
+ &ConfigureWindowAux::new().x(new_x).y(new_y), |
| 2365 |
- .x(new_x) |
|
|
| 2366 |
- .y(new_y), |
|
|
| 2367 |
)?; |
2477 |
)?; |
| 2368 |
self.connection.flush()?; |
2478 |
self.connection.flush()?; |
| 2369 |
} |
2479 |
} |
| @@ -2373,11 +2483,14 @@ impl WindowManager { |
| 2373 |
} |
2483 |
} |
| 2374 |
} |
2484 |
} |
| 2375 |
|
2485 |
|
| 2376 |
- self.connection.ungrab_pointer(x11rb::CURRENT_TIME)?.check()?; |
2486 |
+ self.connection |
|
|
2487 |
+ .ungrab_pointer(x11rb::CURRENT_TIME)? |
|
|
2488 |
+ .check()?; |
| 2377 |
|
2489 |
|
| 2378 |
- let final_client = self.clients.get(&window).map(|c| { |
2490 |
+ let final_client = self |
| 2379 |
- (c.x_position, c.y_position, c.width, c.height) |
2491 |
+ .clients |
| 2380 |
- }); |
2492 |
+ .get(&window) |
|
|
2493 |
+ .map(|c| (c.x_position, c.y_position, c.width, c.height)); |
| 2381 |
|
2494 |
|
| 2382 |
if let Some((x, y, w, h)) = final_client { |
2495 |
if let Some((x, y, w, h)) = final_client { |
| 2383 |
let new_monitor = self.get_monitor_for_rect(x as i32, y as i32, w as i32, h as i32); |
2496 |
let new_monitor = self.get_monitor_for_rect(x as i32, y as i32, w as i32, h as i32); |
| @@ -2392,7 +2505,8 @@ impl WindowManager { |
| 2392 |
} |
2505 |
} |
| 2393 |
|
2506 |
|
| 2394 |
fn resize_window_with_mouse(&mut self, window: Window) -> WmResult<()> { |
2507 |
fn resize_window_with_mouse(&mut self, window: Window) -> WmResult<()> { |
| 2395 |
- let is_fullscreen = self.clients |
2508 |
+ let is_fullscreen = self |
|
|
2509 |
+ .clients |
| 2396 |
.get(&window) |
2510 |
.get(&window) |
| 2397 |
.map(|c| c.is_fullscreen) |
2511 |
.map(|c| c.is_fullscreen) |
| 2398 |
.unwrap_or(false); |
2512 |
.unwrap_or(false); |
| @@ -2402,10 +2516,27 @@ impl WindowManager { |
| 2402 |
} |
2516 |
} |
| 2403 |
|
2517 |
|
| 2404 |
let client_info = self.clients.get(&window).map(|c| { |
2518 |
let client_info = self.clients.get(&window).map(|c| { |
| 2405 |
- (c.x_position, c.y_position, c.width, c.height, c.border_width, c.is_floating, c.monitor_index) |
2519 |
+ ( |
|
|
2520 |
+ c.x_position, |
|
|
2521 |
+ c.y_position, |
|
|
2522 |
+ c.width, |
|
|
2523 |
+ c.height, |
|
|
2524 |
+ c.border_width, |
|
|
2525 |
+ c.is_floating, |
|
|
2526 |
+ c.monitor_index, |
|
|
2527 |
+ ) |
| 2406 |
}); |
2528 |
}); |
| 2407 |
|
2529 |
|
| 2408 |
- let Some((orig_x, orig_y, orig_width, orig_height, border_width, was_floating, monitor_idx)) = client_info else { |
2530 |
+ let Some(( |
|
|
2531 |
+ orig_x, |
|
|
2532 |
+ orig_y, |
|
|
2533 |
+ orig_width, |
|
|
2534 |
+ orig_height, |
|
|
2535 |
+ border_width, |
|
|
2536 |
+ was_floating, |
|
|
2537 |
+ monitor_idx, |
|
|
2538 |
+ )) = client_info |
|
|
2539 |
+ else { |
| 2409 |
return Ok(()); |
2540 |
return Ok(()); |
| 2410 |
}; |
2541 |
}; |
| 2411 |
|
2542 |
|
| @@ -2430,17 +2561,19 @@ impl WindowManager { |
| 2430 |
(orig_height + border_width - 1) as i16, |
2561 |
(orig_height + border_width - 1) as i16, |
| 2431 |
)?; |
2562 |
)?; |
| 2432 |
|
2563 |
|
| 2433 |
- self.connection.grab_pointer( |
2564 |
+ self.connection |
| 2434 |
- false, |
2565 |
+ .grab_pointer( |
| 2435 |
- self.root, |
2566 |
+ false, |
| 2436 |
- (EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE | |
2567 |
+ self.root, |
| 2437 |
- EventMask::BUTTON_PRESS).into(), |
2568 |
+ (EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE | EventMask::BUTTON_PRESS) |
| 2438 |
- GrabMode::ASYNC, |
2569 |
+ .into(), |
| 2439 |
- GrabMode::ASYNC, |
2570 |
+ GrabMode::ASYNC, |
| 2440 |
- x11rb::NONE, |
2571 |
+ GrabMode::ASYNC, |
| 2441 |
- x11rb::NONE, |
2572 |
+ x11rb::NONE, |
| 2442 |
- x11rb::CURRENT_TIME, |
2573 |
+ x11rb::NONE, |
| 2443 |
- )?.reply()?; |
2574 |
+ x11rb::CURRENT_TIME, |
|
|
2575 |
+ )? |
|
|
2576 |
+ .reply()?; |
| 2444 |
|
2577 |
|
| 2445 |
let mut last_time = 0u32; |
2578 |
let mut last_time = 0u32; |
| 2446 |
|
2579 |
|
| @@ -2454,13 +2587,19 @@ impl WindowManager { |
| 2454 |
} |
2587 |
} |
| 2455 |
last_time = e.time; |
2588 |
last_time = e.time; |
| 2456 |
|
2589 |
|
| 2457 |
- let new_width = ((e.root_x as i32 - orig_x as i32 - 2 * border_width as i32 + 1).max(1)) as u32; |
2590 |
+ let new_width = ((e.root_x as i32 - orig_x as i32 - 2 * border_width as i32 |
| 2458 |
- let new_height = ((e.root_y as i32 - orig_y as i32 - 2 * border_width as i32 + 1).max(1)) as u32; |
2591 |
+ + 1) |
|
|
2592 |
+ .max(1)) as u32; |
|
|
2593 |
+ let new_height = ((e.root_y as i32 - orig_y as i32 - 2 * border_width as i32 |
|
|
2594 |
+ + 1) |
|
|
2595 |
+ .max(1)) as u32; |
| 2459 |
|
2596 |
|
| 2460 |
- let should_resize = is_normie || self.clients |
2597 |
+ let should_resize = is_normie |
| 2461 |
- .get(&window) |
2598 |
+ || self |
| 2462 |
- .map(|c| c.is_floating) |
2599 |
+ .clients |
| 2463 |
- .unwrap_or(false); |
2600 |
+ .get(&window) |
|
|
2601 |
+ .map(|c| c.is_floating) |
|
|
2602 |
+ .unwrap_or(false); |
| 2464 |
|
2603 |
|
| 2465 |
if should_resize { |
2604 |
if should_resize { |
| 2466 |
if let Some(client) = self.clients.get(&window).cloned() { |
2605 |
if let Some(client) = self.clients.get(&window).cloned() { |
| @@ -2492,9 +2631,7 @@ impl WindowManager { |
| 2492 |
} |
2631 |
} |
| 2493 |
} |
2632 |
} |
| 2494 |
|
2633 |
|
| 2495 |
- let final_client = self.clients.get(&window).map(|c| { |
2634 |
+ let final_client = self.clients.get(&window).map(|c| (c.width, c.border_width)); |
| 2496 |
- (c.width, c.border_width) |
|
|
| 2497 |
- }); |
|
|
| 2498 |
|
2635 |
|
| 2499 |
if let Some((w, bw)) = final_client { |
2636 |
if let Some((w, bw)) = final_client { |
| 2500 |
self.connection.warp_pointer( |
2637 |
self.connection.warp_pointer( |
| @@ -2509,11 +2646,14 @@ impl WindowManager { |
| 2509 |
)?; |
2646 |
)?; |
| 2510 |
} |
2647 |
} |
| 2511 |
|
2648 |
|
| 2512 |
- self.connection.ungrab_pointer(x11rb::CURRENT_TIME)?.check()?; |
2649 |
+ self.connection |
|
|
2650 |
+ .ungrab_pointer(x11rb::CURRENT_TIME)? |
|
|
2651 |
+ .check()?; |
| 2513 |
|
2652 |
|
| 2514 |
- let final_client_pos = self.clients.get(&window).map(|c| { |
2653 |
+ let final_client_pos = self |
| 2515 |
- (c.x_position, c.y_position, c.width, c.height) |
2654 |
+ .clients |
| 2516 |
- }); |
2655 |
+ .get(&window) |
|
|
2656 |
+ .map(|c| (c.x_position, c.y_position, c.width, c.height)); |
| 2517 |
|
2657 |
|
| 2518 |
if let Some((x, y, w, h)) = final_client_pos { |
2658 |
if let Some((x, y, w, h)) = final_client_pos { |
| 2519 |
let new_monitor = self.get_monitor_for_rect(x as i32, y as i32, w as i32, h as i32); |
2659 |
let new_monitor = self.get_monitor_for_rect(x as i32, y as i32, w as i32, h as i32); |
| @@ -2572,10 +2712,13 @@ impl WindowManager { |
| 2572 |
return Ok(None); |
2712 |
return Ok(None); |
| 2573 |
} |
2713 |
} |
| 2574 |
Event::ButtonPress(ref e) if e.event == self.keybind_overlay.window() => { |
2714 |
Event::ButtonPress(ref e) if e.event == self.keybind_overlay.window() => { |
| 2575 |
- self.connection.allow_events(Allow::REPLAY_POINTER, e.time)?; |
2715 |
+ self.connection |
|
|
2716 |
+ .allow_events(Allow::REPLAY_POINTER, e.time)?; |
| 2576 |
return Ok(None); |
2717 |
return Ok(None); |
| 2577 |
} |
2718 |
} |
| 2578 |
- Event::Expose(ref expose_event) if expose_event.window == self.keybind_overlay.window() => { |
2719 |
+ Event::Expose(ref expose_event) |
|
|
2720 |
+ if expose_event.window == self.keybind_overlay.window() => |
|
|
2721 |
+ { |
| 2579 |
if self.keybind_overlay.is_visible() { |
2722 |
if self.keybind_overlay.is_visible() { |
| 2580 |
if let Err(error) = self.keybind_overlay.draw(&self.connection, &self.font) { |
2723 |
if let Err(error) = self.keybind_overlay.draw(&self.connection, &self.font) { |
| 2581 |
eprintln!("Failed to draw keybind overlay: {:?}", error); |
2724 |
eprintln!("Failed to draw keybind overlay: {:?}", error); |
| @@ -2617,7 +2760,11 @@ impl WindowManager { |
| 2617 |
} |
2760 |
} |
| 2618 |
|
2761 |
|
| 2619 |
if event.atom == AtomEnum::WM_TRANSIENT_FOR.into() { |
2762 |
if event.atom == AtomEnum::WM_TRANSIENT_FOR.into() { |
| 2620 |
- let is_floating = self.clients.get(&event.window).map(|c| c.is_floating).unwrap_or(false); |
2763 |
+ let is_floating = self |
|
|
2764 |
+ .clients |
|
|
2765 |
+ .get(&event.window) |
|
|
2766 |
+ .map(|c| c.is_floating) |
|
|
2767 |
+ .unwrap_or(false); |
| 2621 |
if !is_floating { |
2768 |
if !is_floating { |
| 2622 |
if let Some(parent) = self.get_transient_parent(event.window) { |
2769 |
if let Some(parent) = self.get_transient_parent(event.window) { |
| 2623 |
if self.clients.contains_key(&parent) { |
2770 |
if self.clients.contains_key(&parent) { |
| @@ -2710,7 +2857,10 @@ impl WindowManager { |
| 2710 |
self.gaps_enabled = self.config.gaps_enabled; |
2857 |
self.gaps_enabled = self.config.gaps_enabled; |
| 2711 |
self.error_message = None; |
2858 |
self.error_message = None; |
| 2712 |
if let Err(error) = self.overlay.hide(&self.connection) { |
2859 |
if let Err(error) = self.overlay.hide(&self.connection) { |
| 2713 |
- eprintln!("Failed to hide overlay after config reload: {:?}", error); |
2860 |
+ eprintln!( |
|
|
2861 |
+ "Failed to hide overlay after config reload: {:?}", |
|
|
2862 |
+ error |
|
|
2863 |
+ ); |
| 2714 |
} |
2864 |
} |
| 2715 |
self.apply_layout()?; |
2865 |
self.apply_layout()?; |
| 2716 |
self.update_bar()?; |
2866 |
self.update_bar()?; |
| @@ -2759,7 +2909,8 @@ impl WindowManager { |
| 2759 |
} |
2909 |
} |
| 2760 |
} |
2910 |
} |
| 2761 |
Event::ButtonPress(event) => { |
2911 |
Event::ButtonPress(event) => { |
| 2762 |
- if self.keybind_overlay.is_visible() && event.event != self.keybind_overlay.window() { |
2912 |
+ if self.keybind_overlay.is_visible() && event.event != self.keybind_overlay.window() |
|
|
2913 |
+ { |
| 2763 |
if let Err(error) = self.keybind_overlay.hide(&self.connection) { |
2914 |
if let Err(error) = self.keybind_overlay.hide(&self.connection) { |
| 2764 |
eprintln!("Failed to hide keybind overlay: {:?}", error); |
2915 |
eprintln!("Failed to hide keybind overlay: {:?}", error); |
| 2765 |
} |
2916 |
} |
| @@ -2801,7 +2952,11 @@ impl WindowManager { |
| 2801 |
{ |
2952 |
{ |
| 2802 |
return None; |
2953 |
return None; |
| 2803 |
} |
2954 |
} |
| 2804 |
- let monitor_tags = self.monitors.get(monitor_index).map(|m| m.tagset[m.selected_tags_index]).unwrap_or(0); |
2955 |
+ let monitor_tags = self |
|
|
2956 |
+ .monitors |
|
|
2957 |
+ .get(monitor_index) |
|
|
2958 |
+ .map(|m| m.tagset[m.selected_tags_index]) |
|
|
2959 |
+ .unwrap_or(0); |
| 2805 |
if (client.tags & monitor_tags) != 0 { |
2960 |
if (client.tags & monitor_tags) != 0 { |
| 2806 |
return Some((window, client.name.clone())); |
2961 |
return Some((window, client.name.clone())); |
| 2807 |
} |
2962 |
} |
| @@ -2810,7 +2965,9 @@ impl WindowManager { |
| 2810 |
}) |
2965 |
}) |
| 2811 |
.collect(); |
2966 |
.collect(); |
| 2812 |
|
2967 |
|
| 2813 |
- if let Some(clicked_window) = tab_bar.get_clicked_window(&visible_windows, event.event_x) { |
2968 |
+ if let Some(clicked_window) = |
|
|
2969 |
+ tab_bar.get_clicked_window(&visible_windows, event.event_x) |
|
|
2970 |
+ { |
| 2814 |
self.connection.configure_window( |
2971 |
self.connection.configure_window( |
| 2815 |
clicked_window, |
2972 |
clicked_window, |
| 2816 |
&ConfigureWindowAux::new().stack_mode(StackMode::ABOVE), |
2973 |
&ConfigureWindowAux::new().stack_mode(StackMode::ABOVE), |
| @@ -2822,40 +2979,49 @@ impl WindowManager { |
| 2822 |
self.focus(Some(event.child))?; |
2979 |
self.focus(Some(event.child))?; |
| 2823 |
self.update_tab_bars()?; |
2980 |
self.update_tab_bars()?; |
| 2824 |
|
2981 |
|
| 2825 |
- let state_clean = u16::from(event.state) & !(u16::from(ModMask::LOCK) | u16::from(ModMask::M2)); |
2982 |
+ let state_clean = u16::from(event.state) |
|
|
2983 |
+ & !(u16::from(ModMask::LOCK) | u16::from(ModMask::M2)); |
| 2826 |
let modkey_held = state_clean & u16::from(self.config.modkey) != 0; |
2984 |
let modkey_held = state_clean & u16::from(self.config.modkey) != 0; |
| 2827 |
|
2985 |
|
| 2828 |
if modkey_held && event.detail == ButtonIndex::M1.into() { |
2986 |
if modkey_held && event.detail == ButtonIndex::M1.into() { |
| 2829 |
if self.clients.contains_key(&event.child) { |
2987 |
if self.clients.contains_key(&event.child) { |
| 2830 |
self.drag_window(event.child)?; |
2988 |
self.drag_window(event.child)?; |
| 2831 |
} |
2989 |
} |
| 2832 |
- self.connection.allow_events(Allow::REPLAY_POINTER, event.time)?; |
2990 |
+ self.connection |
|
|
2991 |
+ .allow_events(Allow::REPLAY_POINTER, event.time)?; |
| 2833 |
} else if modkey_held && event.detail == ButtonIndex::M3.into() { |
2992 |
} else if modkey_held && event.detail == ButtonIndex::M3.into() { |
| 2834 |
if self.clients.contains_key(&event.child) { |
2993 |
if self.clients.contains_key(&event.child) { |
| 2835 |
self.resize_window_with_mouse(event.child)?; |
2994 |
self.resize_window_with_mouse(event.child)?; |
| 2836 |
} |
2995 |
} |
| 2837 |
- self.connection.allow_events(Allow::REPLAY_POINTER, event.time)?; |
2996 |
+ self.connection |
|
|
2997 |
+ .allow_events(Allow::REPLAY_POINTER, event.time)?; |
| 2838 |
} else { |
2998 |
} else { |
| 2839 |
- self.connection.allow_events(Allow::REPLAY_POINTER, event.time)?; |
2999 |
+ self.connection |
|
|
3000 |
+ .allow_events(Allow::REPLAY_POINTER, event.time)?; |
| 2840 |
} |
3001 |
} |
| 2841 |
} else if self.windows.contains(&event.event) { |
3002 |
} else if self.windows.contains(&event.event) { |
| 2842 |
self.focus(Some(event.event))?; |
3003 |
self.focus(Some(event.event))?; |
| 2843 |
self.update_tab_bars()?; |
3004 |
self.update_tab_bars()?; |
| 2844 |
|
3005 |
|
| 2845 |
- let state_clean = u16::from(event.state) & !(u16::from(ModMask::LOCK) | u16::from(ModMask::M2)); |
3006 |
+ let state_clean = u16::from(event.state) |
|
|
3007 |
+ & !(u16::from(ModMask::LOCK) | u16::from(ModMask::M2)); |
| 2846 |
let modkey_held = state_clean & u16::from(self.config.modkey) != 0; |
3008 |
let modkey_held = state_clean & u16::from(self.config.modkey) != 0; |
| 2847 |
|
3009 |
|
| 2848 |
if modkey_held && event.detail == ButtonIndex::M1.into() { |
3010 |
if modkey_held && event.detail == ButtonIndex::M1.into() { |
| 2849 |
self.drag_window(event.event)?; |
3011 |
self.drag_window(event.event)?; |
| 2850 |
- self.connection.allow_events(Allow::REPLAY_POINTER, event.time)?; |
3012 |
+ self.connection |
|
|
3013 |
+ .allow_events(Allow::REPLAY_POINTER, event.time)?; |
| 2851 |
} else if modkey_held && event.detail == ButtonIndex::M3.into() { |
3014 |
} else if modkey_held && event.detail == ButtonIndex::M3.into() { |
| 2852 |
self.resize_window_with_mouse(event.event)?; |
3015 |
self.resize_window_with_mouse(event.event)?; |
| 2853 |
- self.connection.allow_events(Allow::REPLAY_POINTER, event.time)?; |
3016 |
+ self.connection |
|
|
3017 |
+ .allow_events(Allow::REPLAY_POINTER, event.time)?; |
| 2854 |
} else { |
3018 |
} else { |
| 2855 |
- self.connection.allow_events(Allow::REPLAY_POINTER, event.time)?; |
3019 |
+ self.connection |
|
|
3020 |
+ .allow_events(Allow::REPLAY_POINTER, event.time)?; |
| 2856 |
} |
3021 |
} |
| 2857 |
} else { |
3022 |
} else { |
| 2858 |
- self.connection.allow_events(Allow::REPLAY_POINTER, event.time)?; |
3023 |
+ self.connection |
|
|
3024 |
+ .allow_events(Allow::REPLAY_POINTER, event.time)?; |
| 2859 |
} |
3025 |
} |
| 2860 |
} |
3026 |
} |
| 2861 |
} |
3027 |
} |
| @@ -2920,10 +3086,13 @@ impl WindowManager { |
| 2920 |
let height_with_border = h + 2 * bw; |
3086 |
let height_with_border = h + 2 * bw; |
| 2921 |
|
3087 |
|
| 2922 |
if (x + w) > monitor.screen_x + monitor.screen_width as i32 && is_floating { |
3088 |
if (x + w) > monitor.screen_x + monitor.screen_width as i32 && is_floating { |
| 2923 |
- x = monitor.screen_x + (monitor.screen_width as i32 / 2 - width_with_border / 2); |
3089 |
+ x = monitor.screen_x |
|
|
3090 |
+ + (monitor.screen_width as i32 / 2 - width_with_border / 2); |
| 2924 |
} |
3091 |
} |
| 2925 |
- if (y + h) > monitor.screen_y + monitor.screen_height as i32 && is_floating { |
3092 |
+ if (y + h) > monitor.screen_y + monitor.screen_height as i32 && is_floating |
| 2926 |
- y = monitor.screen_y + (monitor.screen_height as i32 / 2 - height_with_border / 2); |
3093 |
+ { |
|
|
3094 |
+ y = monitor.screen_y |
|
|
3095 |
+ + (monitor.screen_height as i32 / 2 - height_with_border / 2); |
| 2927 |
} |
3096 |
} |
| 2928 |
|
3097 |
|
| 2929 |
if let Some(c) = self.clients.get_mut(&event.window) { |
3098 |
if let Some(c) = self.clients.get_mut(&event.window) { |
| @@ -2933,8 +3102,10 @@ impl WindowManager { |
| 2933 |
c.height = h as u16; |
3102 |
c.height = h as u16; |
| 2934 |
} |
3103 |
} |
| 2935 |
|
3104 |
|
| 2936 |
- let only_position_change = event.value_mask.contains(ConfigWindow::X) || event.value_mask.contains(ConfigWindow::Y); |
3105 |
+ let only_position_change = event.value_mask.contains(ConfigWindow::X) |
| 2937 |
- let no_size_change = !event.value_mask.contains(ConfigWindow::WIDTH) && !event.value_mask.contains(ConfigWindow::HEIGHT); |
3106 |
+ || event.value_mask.contains(ConfigWindow::Y); |
|
|
3107 |
+ let no_size_change = !event.value_mask.contains(ConfigWindow::WIDTH) |
|
|
3108 |
+ && !event.value_mask.contains(ConfigWindow::HEIGHT); |
| 2938 |
if only_position_change && no_size_change { |
3109 |
if only_position_change && no_size_change { |
| 2939 |
self.send_configure_notify(event.window)?; |
3110 |
self.send_configure_notify(event.window)?; |
| 2940 |
} |
3111 |
} |
| @@ -2998,11 +3169,13 @@ impl WindowManager { |
| 2998 |
} |
3169 |
} |
| 2999 |
} |
3170 |
} |
| 3000 |
} else if event.type_ == self.atoms.net_active_window { |
3171 |
} else if event.type_ == self.atoms.net_active_window { |
| 3001 |
- let selected_window = self.monitors |
3172 |
+ let selected_window = self |
|
|
3173 |
+ .monitors |
| 3002 |
.get(self.selected_monitor) |
3174 |
.get(self.selected_monitor) |
| 3003 |
.and_then(|m| m.selected_client); |
3175 |
.and_then(|m| m.selected_client); |
| 3004 |
|
3176 |
|
| 3005 |
- let is_urgent = self.clients |
3177 |
+ let is_urgent = self |
|
|
3178 |
+ .clients |
| 3006 |
.get(&event.window) |
3179 |
.get(&event.window) |
| 3007 |
.map(|c| c.is_urgent) |
3180 |
.map(|c| c.is_urgent) |
| 3008 |
.unwrap_or(false); |
3181 |
.unwrap_or(false); |
| @@ -3013,7 +3186,8 @@ impl WindowManager { |
| 3013 |
} |
3186 |
} |
| 3014 |
} |
3187 |
} |
| 3015 |
Event::FocusIn(event) => { |
3188 |
Event::FocusIn(event) => { |
| 3016 |
- let selected_window = self.monitors |
3189 |
+ let selected_window = self |
|
|
3190 |
+ .monitors |
| 3017 |
.get(self.selected_monitor) |
3191 |
.get(self.selected_monitor) |
| 3018 |
.and_then(|m| m.selected_client); |
3192 |
.and_then(|m| m.selected_client); |
| 3019 |
|
3193 |
|
| @@ -3055,111 +3229,111 @@ impl WindowManager { |
| 3055 |
if !is_normie { |
3229 |
if !is_normie { |
| 3056 |
let monitor_count = self.monitors.len(); |
3230 |
let monitor_count = self.monitors.len(); |
| 3057 |
for monitor_index in 0..monitor_count { |
3231 |
for monitor_index in 0..monitor_count { |
| 3058 |
- let monitor = &self.monitors[monitor_index]; |
3232 |
+ let monitor = &self.monitors[monitor_index]; |
| 3059 |
- let border_width = self.config.border_width; |
3233 |
+ let border_width = self.config.border_width; |
| 3060 |
|
3234 |
|
| 3061 |
- let gaps = if self.gaps_enabled { |
3235 |
+ let gaps = if self.gaps_enabled { |
| 3062 |
- GapConfig { |
3236 |
+ GapConfig { |
| 3063 |
- inner_horizontal: self.config.gap_inner_horizontal, |
3237 |
+ inner_horizontal: self.config.gap_inner_horizontal, |
| 3064 |
- inner_vertical: self.config.gap_inner_vertical, |
3238 |
+ inner_vertical: self.config.gap_inner_vertical, |
| 3065 |
- outer_horizontal: self.config.gap_outer_horizontal, |
3239 |
+ outer_horizontal: self.config.gap_outer_horizontal, |
| 3066 |
- outer_vertical: self.config.gap_outer_vertical, |
3240 |
+ outer_vertical: self.config.gap_outer_vertical, |
| 3067 |
- } |
3241 |
+ } |
| 3068 |
- } else { |
3242 |
+ } else { |
| 3069 |
- GapConfig { |
3243 |
+ GapConfig { |
| 3070 |
- inner_horizontal: 0, |
3244 |
+ inner_horizontal: 0, |
| 3071 |
- inner_vertical: 0, |
3245 |
+ inner_vertical: 0, |
| 3072 |
- outer_horizontal: 0, |
3246 |
+ outer_horizontal: 0, |
| 3073 |
- outer_vertical: 0, |
3247 |
+ outer_vertical: 0, |
| 3074 |
- } |
3248 |
+ } |
| 3075 |
- }; |
3249 |
+ }; |
| 3076 |
|
3250 |
|
| 3077 |
- let monitor_x = monitor.screen_x; |
3251 |
+ let monitor_x = monitor.screen_x; |
| 3078 |
- let monitor_y = monitor.screen_y; |
3252 |
+ let monitor_y = monitor.screen_y; |
| 3079 |
- let monitor_width = monitor.screen_width; |
3253 |
+ let monitor_width = monitor.screen_width; |
| 3080 |
- let monitor_height = monitor.screen_height; |
3254 |
+ let monitor_height = monitor.screen_height; |
| 3081 |
|
3255 |
|
| 3082 |
- let mut visible: Vec<Window> = Vec::new(); |
3256 |
+ let mut visible: Vec<Window> = Vec::new(); |
| 3083 |
- let mut current = self.next_tiled(monitor.clients_head, monitor); |
3257 |
+ let mut current = self.next_tiled(monitor.clients_head, monitor); |
| 3084 |
- while let Some(window) = current { |
3258 |
+ while let Some(window) = current { |
| 3085 |
- visible.push(window); |
3259 |
+ visible.push(window); |
| 3086 |
- if let Some(client) = self.clients.get(&window) { |
3260 |
+ if let Some(client) = self.clients.get(&window) { |
| 3087 |
- current = self.next_tiled(client.next, monitor); |
3261 |
+ current = self.next_tiled(client.next, monitor); |
| 3088 |
- } else { |
3262 |
+ } else { |
| 3089 |
- break; |
3263 |
+ break; |
|
|
3264 |
+ } |
| 3090 |
} |
3265 |
} |
| 3091 |
- } |
|
|
| 3092 |
|
3266 |
|
| 3093 |
- let bar_height = if self.show_bar { |
3267 |
+ let bar_height = if self.show_bar { |
| 3094 |
- self.bars |
3268 |
+ self.bars |
| 3095 |
- .get(monitor_index) |
3269 |
+ .get(monitor_index) |
| 3096 |
- .map(|bar| bar.height() as u32) |
3270 |
+ .map(|bar| bar.height() as u32) |
| 3097 |
- .unwrap_or(0) |
3271 |
+ .unwrap_or(0) |
| 3098 |
- } else { |
3272 |
+ } else { |
| 3099 |
- 0 |
3273 |
+ 0 |
| 3100 |
- }; |
3274 |
+ }; |
| 3101 |
- let usable_height = monitor_height.saturating_sub(bar_height as i32); |
3275 |
+ let usable_height = monitor_height.saturating_sub(bar_height as i32); |
| 3102 |
- let master_factor = monitor.master_factor; |
3276 |
+ let master_factor = monitor.master_factor; |
| 3103 |
- let num_master = monitor.num_master; |
3277 |
+ let num_master = monitor.num_master; |
| 3104 |
- let smartgaps_enabled = self.config.smartgaps_enabled; |
3278 |
+ let smartgaps_enabled = self.config.smartgaps_enabled; |
| 3105 |
- |
3279 |
+ |
| 3106 |
- let geometries = self.layout.arrange( |
3280 |
+ let geometries = self.layout.arrange( |
| 3107 |
- &visible, |
3281 |
+ &visible, |
| 3108 |
- monitor_width as u32, |
3282 |
+ monitor_width as u32, |
| 3109 |
- usable_height as u32, |
3283 |
+ usable_height as u32, |
| 3110 |
- &gaps, |
3284 |
+ &gaps, |
| 3111 |
- master_factor, |
3285 |
+ master_factor, |
| 3112 |
- num_master, |
3286 |
+ num_master, |
| 3113 |
- smartgaps_enabled, |
3287 |
+ smartgaps_enabled, |
| 3114 |
- ); |
3288 |
+ ); |
| 3115 |
|
3289 |
|
| 3116 |
- for (window, geometry) in visible.iter().zip(geometries.iter()) { |
3290 |
+ for (window, geometry) in visible.iter().zip(geometries.iter()) { |
| 3117 |
- let mut adjusted_width = geometry.width.saturating_sub(2 * border_width); |
3291 |
+ let mut adjusted_width = geometry.width.saturating_sub(2 * border_width); |
| 3118 |
- let mut adjusted_height = geometry.height.saturating_sub(2 * border_width); |
3292 |
+ let mut adjusted_height = geometry.height.saturating_sub(2 * border_width); |
| 3119 |
|
3293 |
|
| 3120 |
- if let Some(client) = self.clients.get(window).cloned() { |
3294 |
+ if let Some(client) = self.clients.get(window).cloned() { |
| 3121 |
- if !client.is_floating { |
3295 |
+ if !client.is_floating { |
| 3122 |
- let (_, _, hint_width, hint_height, _) = self.apply_size_hints( |
3296 |
+ let (_, _, hint_width, hint_height, _) = self.apply_size_hints( |
| 3123 |
- *window, |
3297 |
+ *window, |
| 3124 |
- geometry.x_coordinate as i32, |
3298 |
+ geometry.x_coordinate as i32, |
| 3125 |
- geometry.y_coordinate as i32, |
3299 |
+ geometry.y_coordinate as i32, |
| 3126 |
- adjusted_width as i32, |
3300 |
+ adjusted_width as i32, |
| 3127 |
- adjusted_height as i32, |
3301 |
+ adjusted_height as i32, |
| 3128 |
- ); |
3302 |
+ ); |
| 3129 |
- adjusted_width = hint_width as u32; |
3303 |
+ adjusted_width = hint_width as u32; |
| 3130 |
- adjusted_height = hint_height as u32; |
3304 |
+ adjusted_height = hint_height as u32; |
|
|
3305 |
+ } |
| 3131 |
} |
3306 |
} |
| 3132 |
- } |
|
|
| 3133 |
|
3307 |
|
| 3134 |
- let adjusted_x = geometry.x_coordinate + monitor_x; |
3308 |
+ let adjusted_x = geometry.x_coordinate + monitor_x; |
| 3135 |
- let adjusted_y = geometry.y_coordinate + monitor_y + bar_height as i32; |
3309 |
+ let adjusted_y = geometry.y_coordinate + monitor_y + bar_height as i32; |
| 3136 |
|
3310 |
|
| 3137 |
- if let Some(client) = self.clients.get_mut(window) { |
3311 |
+ if let Some(client) = self.clients.get_mut(window) { |
| 3138 |
- client.x_position = adjusted_x as i16; |
3312 |
+ client.x_position = adjusted_x as i16; |
| 3139 |
- client.y_position = adjusted_y as i16; |
3313 |
+ client.y_position = adjusted_y as i16; |
| 3140 |
- client.width = adjusted_width as u16; |
3314 |
+ client.width = adjusted_width as u16; |
| 3141 |
- client.height = adjusted_height as u16; |
3315 |
+ client.height = adjusted_height as u16; |
| 3142 |
- } |
3316 |
+ } |
| 3143 |
|
3317 |
|
| 3144 |
- self.connection.configure_window( |
3318 |
+ self.connection.configure_window( |
| 3145 |
- *window, |
3319 |
+ *window, |
| 3146 |
- &ConfigureWindowAux::new() |
3320 |
+ &ConfigureWindowAux::new() |
| 3147 |
- .x(adjusted_x) |
3321 |
+ .x(adjusted_x) |
| 3148 |
- .y(adjusted_y) |
3322 |
+ .y(adjusted_y) |
| 3149 |
- .width(adjusted_width) |
3323 |
+ .width(adjusted_width) |
| 3150 |
- .height(adjusted_height) |
3324 |
+ .height(adjusted_height) |
| 3151 |
- .border_width(border_width), |
3325 |
+ .border_width(border_width), |
| 3152 |
- )?; |
3326 |
+ )?; |
| 3153 |
|
3327 |
|
| 3154 |
- if let Some(c) = self.clients.get_mut(window) { |
3328 |
+ if let Some(c) = self.clients.get_mut(window) { |
| 3155 |
- c.x_position = adjusted_x as i16; |
3329 |
+ c.x_position = adjusted_x as i16; |
| 3156 |
- c.y_position = adjusted_y as i16; |
3330 |
+ c.y_position = adjusted_y as i16; |
| 3157 |
- c.width = adjusted_width as u16; |
3331 |
+ c.width = adjusted_width as u16; |
| 3158 |
- c.height = adjusted_height as u16; |
3332 |
+ c.height = adjusted_height as u16; |
| 3159 |
- c.border_width = border_width as u16; |
3333 |
+ c.border_width = border_width as u16; |
|
|
3334 |
+ } |
| 3160 |
} |
3335 |
} |
| 3161 |
} |
3336 |
} |
| 3162 |
- } |
|
|
| 3163 |
} |
3337 |
} |
| 3164 |
|
3338 |
|
| 3165 |
for monitor_index in 0..self.monitors.len() { |
3339 |
for monitor_index in 0..self.monitors.len() { |
| @@ -3195,8 +3369,12 @@ impl WindowManager { |
| 3195 |
}; |
3369 |
}; |
| 3196 |
|
3370 |
|
| 3197 |
let tab_bar_x = (monitor.screen_x + outer_horizontal as i32) as i16; |
3371 |
let tab_bar_x = (monitor.screen_x + outer_horizontal as i32) as i16; |
| 3198 |
- let tab_bar_y = (monitor.screen_y as f32 + bar_height + outer_vertical as f32) as i16; |
3372 |
+ let tab_bar_y = |
| 3199 |
- let tab_bar_width = monitor.screen_width.saturating_sub(2 * outer_horizontal as i32) as u16; |
3373 |
+ (monitor.screen_y as f32 + bar_height + outer_vertical as f32) as i16; |
|
|
3374 |
+ let tab_bar_width = monitor |
|
|
3375 |
+ .screen_width |
|
|
3376 |
+ .saturating_sub(2 * outer_horizontal as i32) |
|
|
3377 |
+ as u16; |
| 3200 |
|
3378 |
|
| 3201 |
if let Err(e) = self.tab_bars[monitor_index].reposition( |
3379 |
if let Err(e) = self.tab_bars[monitor_index].reposition( |
| 3202 |
&self.connection, |
3380 |
&self.connection, |
| @@ -3211,23 +3389,20 @@ impl WindowManager { |
| 3211 |
} |
3389 |
} |
| 3212 |
|
3390 |
|
| 3213 |
for monitor_index in 0..self.tab_bars.len() { |
3391 |
for monitor_index in 0..self.tab_bars.len() { |
| 3214 |
- let has_visible_windows = self |
3392 |
+ let has_visible_windows = self.windows.iter().any(|&window| { |
| 3215 |
- .windows |
3393 |
+ if let Some(client) = self.clients.get(&window) { |
| 3216 |
- .iter() |
3394 |
+ if client.monitor_index != monitor_index |
| 3217 |
- .any(|&window| { |
3395 |
+ || self.floating_windows.contains(&window) |
| 3218 |
- if let Some(client) = self.clients.get(&window) { |
3396 |
+ || self.fullscreen_windows.contains(&window) |
| 3219 |
- if client.monitor_index != monitor_index |
3397 |
+ { |
| 3220 |
- || self.floating_windows.contains(&window) |
3398 |
+ return false; |
| 3221 |
- || self.fullscreen_windows.contains(&window) |
3399 |
+ } |
| 3222 |
- { |
3400 |
+ if let Some(monitor) = self.monitors.get(monitor_index) { |
| 3223 |
- return false; |
3401 |
+ return (client.tags & monitor.tagset[monitor.selected_tags_index]) != 0; |
| 3224 |
- } |
|
|
| 3225 |
- if let Some(monitor) = self.monitors.get(monitor_index) { |
|
|
| 3226 |
- return (client.tags & monitor.tagset[monitor.selected_tags_index]) != 0; |
|
|
| 3227 |
- } |
|
|
| 3228 |
} |
3402 |
} |
| 3229 |
- false |
3403 |
+ } |
| 3230 |
- }); |
3404 |
+ false |
|
|
3405 |
+ }); |
| 3231 |
|
3406 |
|
| 3232 |
if is_tabbed && has_visible_windows { |
3407 |
if is_tabbed && has_visible_windows { |
| 3233 |
if let Err(e) = self.tab_bars[monitor_index].show(&self.connection) { |
3408 |
if let Err(e) = self.tab_bars[monitor_index].show(&self.connection) { |
| @@ -3256,7 +3431,13 @@ impl WindowManager { |
| 3256 |
fn send_configure_notify(&self, window: Window) -> WmResult<()> { |
3431 |
fn send_configure_notify(&self, window: Window) -> WmResult<()> { |
| 3257 |
let client = self.clients.get(&window); |
3432 |
let client = self.clients.get(&window); |
| 3258 |
let (x, y, w, h, bw) = if let Some(c) = client { |
3433 |
let (x, y, w, h, bw) = if let Some(c) = client { |
| 3259 |
- (c.x_position, c.y_position, c.width, c.height, c.border_width) |
3434 |
+ ( |
|
|
3435 |
+ c.x_position, |
|
|
3436 |
+ c.y_position, |
|
|
3437 |
+ c.width, |
|
|
3438 |
+ c.height, |
|
|
3439 |
+ c.border_width, |
|
|
3440 |
+ ) |
| 3260 |
} else { |
3441 |
} else { |
| 3261 |
let geom = self.connection.get_geometry(window)?.reply()?; |
3442 |
let geom = self.connection.get_geometry(window)?.reply()?; |
| 3262 |
(geom.x, geom.y, geom.width, geom.height, geom.border_width) |
3443 |
(geom.x, geom.y, geom.width, geom.height, geom.border_width) |
| @@ -3276,18 +3457,15 @@ impl WindowManager { |
| 3276 |
override_redirect: false, |
3457 |
override_redirect: false, |
| 3277 |
}; |
3458 |
}; |
| 3278 |
|
3459 |
|
| 3279 |
- self.connection.send_event( |
3460 |
+ self.connection |
| 3280 |
- false, |
3461 |
+ .send_event(false, window, EventMask::STRUCTURE_NOTIFY, event)?; |
| 3281 |
- window, |
|
|
| 3282 |
- EventMask::STRUCTURE_NOTIFY, |
|
|
| 3283 |
- event, |
|
|
| 3284 |
- )?; |
|
|
| 3285 |
|
3462 |
|
| 3286 |
Ok(()) |
3463 |
Ok(()) |
| 3287 |
} |
3464 |
} |
| 3288 |
|
3465 |
|
| 3289 |
fn update_size_hints(&mut self, window: Window) -> WmResult<()> { |
3466 |
fn update_size_hints(&mut self, window: Window) -> WmResult<()> { |
| 3290 |
- let size_hints = self.connection |
3467 |
+ let size_hints = self |
|
|
3468 |
+ .connection |
| 3291 |
.get_property( |
3469 |
.get_property( |
| 3292 |
false, |
3470 |
false, |
| 3293 |
window, |
3471 |
window, |
| @@ -3361,8 +3539,10 @@ impl WindowManager { |
| 3361 |
} |
3539 |
} |
| 3362 |
|
3540 |
|
| 3363 |
if flags & P_ASPECT != 0 { |
3541 |
if flags & P_ASPECT != 0 { |
| 3364 |
- client.min_aspect = (read_u32(MIN_ASPECT_Y) as f32) / (read_u32(MIN_ASPECT_X) as f32).max(1.0); |
3542 |
+ client.min_aspect = |
| 3365 |
- client.max_aspect = (read_u32(MAX_ASPECT_X) as f32) / (read_u32(MAX_ASPECT_Y) as f32).max(1.0); |
3543 |
+ (read_u32(MIN_ASPECT_Y) as f32) / (read_u32(MIN_ASPECT_X) as f32).max(1.0); |
|
|
3544 |
+ client.max_aspect = |
|
|
3545 |
+ (read_u32(MAX_ASPECT_X) as f32) / (read_u32(MAX_ASPECT_Y) as f32).max(1.0); |
| 3366 |
} else { |
3546 |
} else { |
| 3367 |
client.min_aspect = 0.0; |
3547 |
client.min_aspect = 0.0; |
| 3368 |
client.max_aspect = 0.0; |
3548 |
client.max_aspect = 0.0; |
| @@ -3379,7 +3559,8 @@ impl WindowManager { |
| 3379 |
} |
3559 |
} |
| 3380 |
|
3560 |
|
| 3381 |
fn update_window_title(&mut self, window: Window) -> WmResult<()> { |
3561 |
fn update_window_title(&mut self, window: Window) -> WmResult<()> { |
| 3382 |
- let net_name = self.connection |
3562 |
+ let net_name = self |
|
|
3563 |
+ .connection |
| 3383 |
.get_property( |
3564 |
.get_property( |
| 3384 |
false, |
3565 |
false, |
| 3385 |
window, |
3566 |
window, |
| @@ -3402,7 +3583,8 @@ impl WindowManager { |
| 3402 |
} |
3583 |
} |
| 3403 |
} |
3584 |
} |
| 3404 |
|
3585 |
|
| 3405 |
- let wm_name = self.connection |
3586 |
+ let wm_name = self |
|
|
3587 |
+ .connection |
| 3406 |
.get_property( |
3588 |
.get_property( |
| 3407 |
false, |
3589 |
false, |
| 3408 |
window, |
3590 |
window, |
| @@ -3425,14 +3607,10 @@ impl WindowManager { |
| 3425 |
} |
3607 |
} |
| 3426 |
|
3608 |
|
| 3427 |
fn update_window_hints(&mut self, window: Window) -> WmResult<()> { |
3609 |
fn update_window_hints(&mut self, window: Window) -> WmResult<()> { |
| 3428 |
- let hints_reply = self.connection.get_property( |
3610 |
+ let hints_reply = self |
| 3429 |
- false, |
3611 |
+ .connection |
| 3430 |
- window, |
3612 |
+ .get_property(false, window, AtomEnum::WM_HINTS, AtomEnum::WM_HINTS, 0, 9)? |
| 3431 |
- AtomEnum::WM_HINTS, |
3613 |
+ .reply(); |
| 3432 |
- AtomEnum::WM_HINTS, |
|
|
| 3433 |
- 0, |
|
|
| 3434 |
- 9, |
|
|
| 3435 |
- )?.reply(); |
|
|
| 3436 |
|
3614 |
|
| 3437 |
if let Ok(hints) = hints_reply { |
3615 |
if let Ok(hints) = hints_reply { |
| 3438 |
if hints.value.len() >= 4 { |
3616 |
if hints.value.len() >= 4 { |
| @@ -3443,7 +3621,8 @@ impl WindowManager { |
| 3443 |
hints.value[3], |
3621 |
hints.value[3], |
| 3444 |
]); |
3622 |
]); |
| 3445 |
|
3623 |
|
| 3446 |
- let selected_window = self.monitors |
3624 |
+ let selected_window = self |
|
|
3625 |
+ .monitors |
| 3447 |
.get(self.selected_monitor) |
3626 |
.get(self.selected_monitor) |
| 3448 |
.and_then(|m| m.selected_client); |
3627 |
.and_then(|m| m.selected_client); |
| 3449 |
|
3628 |
|
| @@ -3490,13 +3669,16 @@ impl WindowManager { |
| 3490 |
} |
3669 |
} |
| 3491 |
|
3670 |
|
| 3492 |
fn update_window_type(&mut self, window: Window) -> WmResult<()> { |
3671 |
fn update_window_type(&mut self, window: Window) -> WmResult<()> { |
| 3493 |
- if let Ok(Some(state_atom)) = self.get_window_atom_property(window, self.atoms.net_wm_state) { |
3672 |
+ if let Ok(Some(state_atom)) = self.get_window_atom_property(window, self.atoms.net_wm_state) |
|
|
3673 |
+ { |
| 3494 |
if state_atom == self.atoms.net_wm_state_fullscreen { |
3674 |
if state_atom == self.atoms.net_wm_state_fullscreen { |
| 3495 |
self.set_window_fullscreen(window, true)?; |
3675 |
self.set_window_fullscreen(window, true)?; |
| 3496 |
} |
3676 |
} |
| 3497 |
} |
3677 |
} |
| 3498 |
|
3678 |
|
| 3499 |
- if let Ok(Some(type_atom)) = self.get_window_atom_property(window, self.atoms.net_wm_window_type) { |
3679 |
+ if let Ok(Some(type_atom)) = |
|
|
3680 |
+ self.get_window_atom_property(window, self.atoms.net_wm_window_type) |
|
|
3681 |
+ { |
| 3500 |
if type_atom == self.atoms.net_wm_window_type_dialog { |
3682 |
if type_atom == self.atoms.net_wm_window_type_dialog { |
| 3501 |
if let Some(client) = self.clients.get_mut(&window) { |
3683 |
if let Some(client) = self.clients.get_mut(&window) { |
| 3502 |
client.is_floating = true; |
3684 |
client.is_floating = true; |
| @@ -3508,16 +3690,40 @@ impl WindowManager { |
| 3508 |
Ok(()) |
3690 |
Ok(()) |
| 3509 |
} |
3691 |
} |
| 3510 |
|
3692 |
|
| 3511 |
- fn apply_size_hints(&mut self, window: Window, mut x: i32, mut y: i32, mut w: i32, mut h: i32) -> (i32, i32, i32, i32, bool) { |
3693 |
+ fn apply_size_hints( |
|
|
3694 |
+ &mut self, |
|
|
3695 |
+ window: Window, |
|
|
3696 |
+ mut x: i32, |
|
|
3697 |
+ mut y: i32, |
|
|
3698 |
+ mut w: i32, |
|
|
3699 |
+ mut h: i32, |
|
|
3700 |
+ ) -> (i32, i32, i32, i32, bool) { |
| 3512 |
let bh = 20; |
3701 |
let bh = 20; |
| 3513 |
|
3702 |
|
| 3514 |
- let (client_x, client_y, client_w, client_h, bw, monitor_index, is_floating, mut hints_valid) = { |
3703 |
+ let ( |
|
|
3704 |
+ client_x, |
|
|
3705 |
+ client_y, |
|
|
3706 |
+ client_w, |
|
|
3707 |
+ client_h, |
|
|
3708 |
+ bw, |
|
|
3709 |
+ monitor_index, |
|
|
3710 |
+ is_floating, |
|
|
3711 |
+ mut hints_valid, |
|
|
3712 |
+ ) = { |
| 3515 |
let client = match self.clients.get(&window) { |
3713 |
let client = match self.clients.get(&window) { |
| 3516 |
Some(c) => c, |
3714 |
Some(c) => c, |
| 3517 |
None => return (x, y, w, h, false), |
3715 |
None => return (x, y, w, h, false), |
| 3518 |
}; |
3716 |
}; |
| 3519 |
- (client.x_position as i32, client.y_position as i32, client.width as i32, client.height as i32, |
3717 |
+ ( |
| 3520 |
- client.border_width as i32, client.monitor_index, client.is_floating, client.hints_valid) |
3718 |
+ client.x_position as i32, |
|
|
3719 |
+ client.y_position as i32, |
|
|
3720 |
+ client.width as i32, |
|
|
3721 |
+ client.height as i32, |
|
|
3722 |
+ client.border_width as i32, |
|
|
3723 |
+ client.monitor_index, |
|
|
3724 |
+ client.is_floating, |
|
|
3725 |
+ client.hints_valid, |
|
|
3726 |
+ ) |
| 3521 |
}; |
3727 |
}; |
| 3522 |
|
3728 |
|
| 3523 |
let monitor = &self.monitors[monitor_index]; |
3729 |
let monitor = &self.monitors[monitor_index]; |
| @@ -3550,16 +3756,39 @@ impl WindowManager { |
| 3550 |
if is_floating || self.layout.name() == "normie" { |
3756 |
if is_floating || self.layout.name() == "normie" { |
| 3551 |
if !hints_valid { |
3757 |
if !hints_valid { |
| 3552 |
let _ = self.update_size_hints(window); |
3758 |
let _ = self.update_size_hints(window); |
| 3553 |
- hints_valid = self.clients.get(&window).map(|c| c.hints_valid).unwrap_or(false); |
3759 |
+ hints_valid = self |
|
|
3760 |
+ .clients |
|
|
3761 |
+ .get(&window) |
|
|
3762 |
+ .map(|c| c.hints_valid) |
|
|
3763 |
+ .unwrap_or(false); |
| 3554 |
} |
3764 |
} |
| 3555 |
|
3765 |
|
| 3556 |
if hints_valid { |
3766 |
if hints_valid { |
| 3557 |
- let (base_width, base_height, min_width, min_height, max_width, max_height, |
3767 |
+ let ( |
| 3558 |
- inc_width, inc_height, min_aspect, max_aspect) = { |
3768 |
+ base_width, |
|
|
3769 |
+ base_height, |
|
|
3770 |
+ min_width, |
|
|
3771 |
+ min_height, |
|
|
3772 |
+ max_width, |
|
|
3773 |
+ max_height, |
|
|
3774 |
+ inc_width, |
|
|
3775 |
+ inc_height, |
|
|
3776 |
+ min_aspect, |
|
|
3777 |
+ max_aspect, |
|
|
3778 |
+ ) = { |
| 3559 |
let client = self.clients.get(&window).unwrap(); |
3779 |
let client = self.clients.get(&window).unwrap(); |
| 3560 |
- (client.base_width, client.base_height, client.min_width, client.min_height, |
3780 |
+ ( |
| 3561 |
- client.max_width, client.max_height, client.increment_width, client.increment_height, |
3781 |
+ client.base_width, |
| 3562 |
- client.min_aspect, client.max_aspect) |
3782 |
+ client.base_height, |
|
|
3783 |
+ client.min_width, |
|
|
3784 |
+ client.min_height, |
|
|
3785 |
+ client.max_width, |
|
|
3786 |
+ client.max_height, |
|
|
3787 |
+ client.increment_width, |
|
|
3788 |
+ client.increment_height, |
|
|
3789 |
+ client.min_aspect, |
|
|
3790 |
+ client.max_aspect, |
|
|
3791 |
+ ) |
| 3563 |
}; |
3792 |
}; |
| 3564 |
|
3793 |
|
| 3565 |
let base_is_min = base_width == min_width && base_height == min_height; |
3794 |
let base_is_min = base_width == min_width && base_height == min_height; |
| @@ -3687,7 +3916,9 @@ impl WindowManager { |
| 3687 |
if let Some(current_client) = self.clients.get(¤t_window) { |
3916 |
if let Some(current_client) = self.clients.get(¤t_window) { |
| 3688 |
if current_client.next == Some(window) { |
3917 |
if current_client.next == Some(window) { |
| 3689 |
let new_next = self.clients.get(&window).and_then(|c| c.next); |
3918 |
let new_next = self.clients.get(&window).and_then(|c| c.next); |
| 3690 |
- if let Some(current_client_mut) = self.clients.get_mut(¤t_window) { |
3919 |
+ if let Some(current_client_mut) = |
|
|
3920 |
+ self.clients.get_mut(¤t_window) |
|
|
3921 |
+ { |
| 3691 |
current_client_mut.next = new_next; |
3922 |
current_client_mut.next = new_next; |
| 3692 |
} |
3923 |
} |
| 3693 |
break; |
3924 |
break; |
| @@ -3745,8 +3976,11 @@ impl WindowManager { |
| 3745 |
while let Some(current_window) = current { |
3976 |
while let Some(current_window) = current { |
| 3746 |
if let Some(current_client) = self.clients.get(¤t_window) { |
3977 |
if let Some(current_client) = self.clients.get(¤t_window) { |
| 3747 |
if current_client.stack_next == Some(window) { |
3978 |
if current_client.stack_next == Some(window) { |
| 3748 |
- let new_stack_next = self.clients.get(&window).and_then(|c| c.stack_next); |
3979 |
+ let new_stack_next = |
| 3749 |
- if let Some(current_client_mut) = self.clients.get_mut(¤t_window) { |
3980 |
+ self.clients.get(&window).and_then(|c| c.stack_next); |
|
|
3981 |
+ if let Some(current_client_mut) = |
|
|
3982 |
+ self.clients.get_mut(¤t_window) |
|
|
3983 |
+ { |
| 3750 |
current_client_mut.stack_next = new_stack_next; |
3984 |
current_client_mut.stack_next = new_stack_next; |
| 3751 |
} |
3985 |
} |
| 3752 |
break; |
3986 |
break; |