|
|
@@ -127,11 +127,9 @@ pub struct WindowManager { |
| 127 |
127 |
gaps_enabled: bool, |
| 128 |
128 |
floating_windows: HashSet<Window>, |
| 129 |
129 |
fullscreen_windows: HashSet<Window>, |
| 130 |
|
- floating_geometry_before_fullscreen: HashMap<Window, (i16, i16, u16, u16, u16)>, |
| 131 |
130 |
bars: Vec<Bar>, |
| 132 |
131 |
tab_bars: Vec<crate::tab_bar::TabBar>, |
| 133 |
132 |
show_bar: bool, |
| 134 |
|
- last_layout: Option<&'static str>, |
| 135 |
133 |
monitors: Vec<Monitor>, |
| 136 |
134 |
selected_monitor: usize, |
| 137 |
135 |
atoms: AtomCache, |
|
|
@@ -286,11 +284,9 @@ impl WindowManager { |
| 286 |
284 |
gaps_enabled, |
| 287 |
285 |
floating_windows: HashSet::new(), |
| 288 |
286 |
fullscreen_windows: HashSet::new(), |
| 289 |
|
- floating_geometry_before_fullscreen: HashMap::new(), |
| 290 |
287 |
bars, |
| 291 |
288 |
tab_bars, |
| 292 |
289 |
show_bar: true, |
| 293 |
|
- last_layout: None, |
| 294 |
290 |
monitors, |
| 295 |
291 |
selected_monitor: 0, |
| 296 |
292 |
atoms, |
|
|
@@ -316,16 +312,7 @@ impl WindowManager { |
| 316 |
312 |
Ok(window_manager) |
| 317 |
313 |
} |
| 318 |
314 |
|
| 319 |
|
- pub fn show_migration_overlay(&mut self) { |
| 320 |
|
- let message = "We are on version 0.8.0 now.\n\n\ |
| 321 |
|
- Your config file has been deprecated once again.\n\ |
| 322 |
|
- Backup your current config, and run oxwm --init to generate a new one with correct values.\n\n\ |
| 323 |
|
- Please reach out to Tony, or check out the\n\ |
| 324 |
|
- documentation for help with migration.\n\n\ |
| 325 |
|
- We appreciate you testing oxwm!\n\n\ |
| 326 |
|
- Press Mod+Shift+/ to see keybinds\n\ |
| 327 |
|
- Press Mod+Shift+R to reload after fixing your config"; |
| 328 |
|
- |
|
315 |
+ pub fn show_startup_config_error(&mut self, error: &str) { |
| 329 |
316 |
let monitor = &self.monitors[self.selected_monitor]; |
| 330 |
317 |
let monitor_x = monitor.screen_x as i16; |
| 331 |
318 |
let monitor_y = monitor.screen_y as i16; |
|
|
@@ -335,19 +322,19 @@ impl WindowManager { |
| 335 |
322 |
if let Err(e) = self.overlay.show_error( |
| 336 |
323 |
&self.connection, |
| 337 |
324 |
&self.font, |
| 338 |
|
- message, |
|
325 |
+ error, |
| 339 |
326 |
monitor_x, |
| 340 |
327 |
monitor_y, |
| 341 |
328 |
screen_width, |
| 342 |
329 |
screen_height, |
| 343 |
330 |
) { |
| 344 |
|
- eprintln!("Failed to show migration overlay: {:?}", e); |
|
331 |
+ eprintln!("Failed to show config error overlay: {:?}", e); |
| 345 |
332 |
} |
| 346 |
333 |
} |
| 347 |
334 |
|
| 348 |
335 |
fn try_reload_config(&mut self) -> Result<(), String> { |
| 349 |
336 |
let lua_path = |
| 350 |
|
- self.config.path.take().ok_or( |
|
337 |
+ self.config.path.as_ref().ok_or( |
| 351 |
338 |
"Could not find config file. Config path should've been set while loading", |
| 352 |
339 |
)?; |
| 353 |
340 |
|
|
|
@@ -355,7 +342,7 @@ impl WindowManager { |
| 355 |
342 |
return Err("Could not find config file, has it been moved?".to_string()); |
| 356 |
343 |
} |
| 357 |
344 |
|
| 358 |
|
- let config_str = std::fs::read_to_string(&lua_path) |
|
345 |
+ let config_str = std::fs::read_to_string(lua_path) |
| 359 |
346 |
.map_err(|e| format!("Failed to read config: {}", e))?; |
| 360 |
347 |
|
| 361 |
348 |
let config_dir = lua_path.parent(); |
|
|
@@ -363,8 +350,10 @@ impl WindowManager { |
| 363 |
350 |
let new_config = crate::config::parse_lua_config(&config_str, config_dir) |
| 364 |
351 |
.map_err(|e| format!("{}", e))?; |
| 365 |
352 |
|
|
353 |
+ let lua_path = self.config.path.take(); |
|
354 |
+ |
| 366 |
355 |
self.config = new_config; |
| 367 |
|
- self.config.path = Some(lua_path); |
|
356 |
+ self.config.path = lua_path; |
| 368 |
357 |
self.error_message = None; |
| 369 |
358 |
|
| 370 |
359 |
for bar in &mut self.bars { |
|
|
@@ -546,10 +535,10 @@ impl WindowManager { |
| 546 |
535 |
} |
| 547 |
536 |
let focused = focused.unwrap(); |
| 548 |
537 |
|
| 549 |
|
- if let Some(client) = self.clients.get(&focused) { |
| 550 |
|
- if client.is_fullscreen { |
| 551 |
|
- return Ok(()); |
| 552 |
|
- } |
|
538 |
+ if let Some(client) = self.clients.get(&focused) |
|
539 |
+ && client.is_fullscreen |
|
540 |
+ { |
|
541 |
+ return Ok(()); |
| 553 |
542 |
} |
| 554 |
543 |
|
| 555 |
544 |
let (is_fixed, x, y, w, h) = if let Some(client) = self.clients.get(&focused) { |
|
|
@@ -594,7 +583,7 @@ impl WindowManager { |
| 594 |
583 |
|
| 595 |
584 |
fn set_master_factor(&mut self, delta: f32) -> WmResult<()> { |
| 596 |
585 |
if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
| 597 |
|
- let new_mfact = (monitor.master_factor + delta).max(0.05).min(0.95); |
|
586 |
+ let new_mfact = (monitor.master_factor + delta).clamp(0.05, 0.95); |
| 598 |
587 |
monitor.master_factor = new_mfact; |
| 599 |
588 |
self.apply_layout()?; |
| 600 |
589 |
} |
|
|
@@ -670,9 +659,13 @@ impl WindowManager { |
| 670 |
659 |
for (monitor_index, monitor) in self.monitors.iter().enumerate() { |
| 671 |
660 |
if let Some(bar) = self.bars.get_mut(monitor_index) { |
| 672 |
661 |
let mut occupied_tags: TagMask = 0; |
|
662 |
+ let mut urgent_tags: TagMask = 0; |
| 673 |
663 |
for client in self.clients.values() { |
| 674 |
664 |
if client.monitor_index == monitor_index { |
| 675 |
665 |
occupied_tags |= client.tags; |
|
666 |
+ if client.is_urgent { |
|
667 |
+ urgent_tags |= client.tags; |
|
668 |
+ } |
| 676 |
669 |
} |
| 677 |
670 |
} |
| 678 |
671 |
|
|
|
@@ -684,6 +677,7 @@ impl WindowManager { |
| 684 |
677 |
self.display, |
| 685 |
678 |
monitor.tagset[monitor.selected_tags_index], |
| 686 |
679 |
occupied_tags, |
|
680 |
+ urgent_tags, |
| 687 |
681 |
draw_blocks, |
| 688 |
682 |
&layout_symbol, |
| 689 |
683 |
keychord_indicator.as_deref(), |
|
|
@@ -744,13 +738,6 @@ impl WindowManager { |
| 744 |
738 |
} |
| 745 |
739 |
} |
| 746 |
740 |
KeyAction::ToggleFullScreen => { |
| 747 |
|
- // Disable gaps and save previous state in config if not already in fullscreen |
| 748 |
|
- if self.fullscreen_windows.is_empty() { |
| 749 |
|
- self.config.gaps_enabled = std::mem::take(&mut self.gaps_enabled); |
| 750 |
|
- } else { |
| 751 |
|
- self.gaps_enabled = self.config.gaps_enabled; |
| 752 |
|
- } |
| 753 |
|
- |
| 754 |
741 |
self.fullscreen()?; |
| 755 |
742 |
self.restack()?; |
| 756 |
743 |
} |
|
|
@@ -794,11 +781,13 @@ impl WindowManager { |
| 794 |
781 |
KeyAction::FocusStack => { |
| 795 |
782 |
if let Arg::Int(direction) = arg { |
| 796 |
783 |
self.focusstack(*direction)?; |
|
784 |
+ self.restack()?; |
| 797 |
785 |
} |
| 798 |
786 |
} |
| 799 |
787 |
KeyAction::MoveStack => { |
| 800 |
788 |
if let Arg::Int(direction) = arg { |
| 801 |
789 |
self.move_stack(*direction)?; |
|
790 |
+ self.restack()?; |
| 802 |
791 |
} |
| 803 |
792 |
} |
| 804 |
793 |
KeyAction::Quit | KeyAction::Restart => { |
|
|
@@ -993,10 +982,10 @@ impl WindowManager { |
| 993 |
982 |
) -> WmResult<()> { |
| 994 |
983 |
let current_monitor_index = self.clients.get(&window).map(|c| c.monitor_index); |
| 995 |
984 |
|
| 996 |
|
- if let Some(current_idx) = current_monitor_index { |
| 997 |
|
- if current_idx == target_monitor_index { |
| 998 |
|
- return Ok(()); |
| 999 |
|
- } |
|
985 |
+ if let Some(current_idx) = current_monitor_index |
|
986 |
+ && current_idx == target_monitor_index |
|
987 |
+ { |
|
988 |
+ return Ok(()); |
| 1000 |
989 |
} |
| 1001 |
990 |
|
| 1002 |
991 |
self.unfocus(window)?; |
|
|
@@ -1030,12 +1019,10 @@ impl WindowManager { |
| 1030 |
1019 |
} else { |
| 1031 |
1020 |
Some(0) |
| 1032 |
1021 |
} |
|
1022 |
+ } else if self.selected_monitor == 0 { |
|
1023 |
+ Some(self.monitors.len() - 1) |
| 1033 |
1024 |
} else { |
| 1034 |
|
- if self.selected_monitor == 0 { |
| 1035 |
|
- Some(self.monitors.len() - 1) |
| 1036 |
|
- } else { |
| 1037 |
|
- Some(self.selected_monitor - 1) |
| 1038 |
|
- } |
|
1025 |
+ Some(self.selected_monitor - 1) |
| 1039 |
1026 |
} |
| 1040 |
1027 |
} |
| 1041 |
1028 |
|
|
|
@@ -1405,34 +1392,34 @@ impl WindowManager { |
| 1405 |
1392 |
.get_property(false, window, AtomEnum::WM_HINTS, AtomEnum::WM_HINTS, 0, 9)? |
| 1406 |
1393 |
.reply(); |
| 1407 |
1394 |
|
| 1408 |
|
- if let Ok(hints) = hints_reply { |
| 1409 |
|
- if hints.value.len() >= 4 { |
| 1410 |
|
- let mut flags = u32::from_ne_bytes([ |
| 1411 |
|
- hints.value[0], |
| 1412 |
|
- hints.value[1], |
| 1413 |
|
- hints.value[2], |
| 1414 |
|
- hints.value[3], |
| 1415 |
|
- ]); |
| 1416 |
|
- |
| 1417 |
|
- if urgent { |
| 1418 |
|
- flags |= 256; |
| 1419 |
|
- } else { |
| 1420 |
|
- flags &= !256; |
| 1421 |
|
- } |
|
1395 |
+ if let Ok(hints) = hints_reply |
|
1396 |
+ && hints.value.len() >= 4 |
|
1397 |
+ { |
|
1398 |
+ let mut flags = u32::from_ne_bytes([ |
|
1399 |
+ hints.value[0], |
|
1400 |
+ hints.value[1], |
|
1401 |
+ hints.value[2], |
|
1402 |
+ hints.value[3], |
|
1403 |
+ ]); |
|
1404 |
+ |
|
1405 |
+ if urgent { |
|
1406 |
+ flags |= 256; |
|
1407 |
+ } else { |
|
1408 |
+ flags &= !256; |
|
1409 |
+ } |
| 1422 |
1410 |
|
| 1423 |
|
- let mut new_hints = hints.value.clone(); |
| 1424 |
|
- new_hints[0..4].copy_from_slice(&flags.to_ne_bytes()); |
|
1411 |
+ let mut new_hints = hints.value.clone(); |
|
1412 |
+ new_hints[0..4].copy_from_slice(&flags.to_ne_bytes()); |
| 1425 |
1413 |
|
| 1426 |
|
- self.connection.change_property( |
| 1427 |
|
- PropMode::REPLACE, |
| 1428 |
|
- window, |
| 1429 |
|
- AtomEnum::WM_HINTS, |
| 1430 |
|
- AtomEnum::WM_HINTS, |
| 1431 |
|
- 32, |
| 1432 |
|
- new_hints.len() as u32 / 4, |
| 1433 |
|
- &new_hints, |
| 1434 |
|
- )?; |
| 1435 |
|
- } |
|
1414 |
+ self.connection.change_property( |
|
1415 |
+ PropMode::REPLACE, |
|
1416 |
+ window, |
|
1417 |
+ AtomEnum::WM_HINTS, |
|
1418 |
+ AtomEnum::WM_HINTS, |
|
1419 |
+ 32, |
|
1420 |
+ new_hints.len() as u32 / 4, |
|
1421 |
+ &new_hints, |
|
1422 |
+ )?; |
| 1436 |
1423 |
} |
| 1437 |
1424 |
|
| 1438 |
1425 |
Ok(()) |
|
|
@@ -1459,163 +1446,16 @@ impl WindowManager { |
| 1459 |
1446 |
} |
| 1460 |
1447 |
|
| 1461 |
1448 |
fn fullscreen(&mut self) -> WmResult<()> { |
| 1462 |
|
- if self.show_bar { |
| 1463 |
|
- let Some(focused_window) = self |
| 1464 |
|
- .monitors |
| 1465 |
|
- .get(self.selected_monitor) |
| 1466 |
|
- .and_then(|m| m.selected_client) |
| 1467 |
|
- else { |
| 1468 |
|
- return Ok(()); |
| 1469 |
|
- }; |
| 1470 |
|
- |
| 1471 |
|
- self.fullscreen_windows.insert(focused_window); |
| 1472 |
|
- |
| 1473 |
|
- let windows: Vec<Window> = self |
| 1474 |
|
- .windows |
| 1475 |
|
- .iter() |
| 1476 |
|
- .filter(|&&w| self.is_window_visible(w)) |
| 1477 |
|
- .copied() |
| 1478 |
|
- .collect(); |
| 1479 |
|
- |
| 1480 |
|
- for window in &windows { |
| 1481 |
|
- if let Ok(geom) = self.connection.get_geometry(*window)?.reply() { |
| 1482 |
|
- self.floating_geometry_before_fullscreen.insert( |
| 1483 |
|
- *window, |
| 1484 |
|
- ( |
| 1485 |
|
- geom.x, |
| 1486 |
|
- geom.y, |
| 1487 |
|
- geom.width, |
| 1488 |
|
- geom.height, |
| 1489 |
|
- geom.border_width as u16, |
| 1490 |
|
- ), |
| 1491 |
|
- ); |
| 1492 |
|
- } |
| 1493 |
|
- } |
| 1494 |
|
- |
| 1495 |
|
- self.last_layout = Some(self.layout.name()); |
| 1496 |
|
- if let Ok(layout) = layout_from_str("monocle") { |
| 1497 |
|
- self.layout = layout; |
| 1498 |
|
- } |
| 1499 |
|
- self.toggle_bar()?; |
| 1500 |
|
- self.apply_layout()?; |
| 1501 |
|
- |
| 1502 |
|
- for window in &windows { |
| 1503 |
|
- self.connection.configure_window( |
| 1504 |
|
- *window, |
| 1505 |
|
- &x11rb::protocol::xproto::ConfigureWindowAux::new().border_width(0), |
| 1506 |
|
- )?; |
| 1507 |
|
- } |
| 1508 |
|
- |
| 1509 |
|
- let border_width = self.config.border_width; |
| 1510 |
|
- let floating_windows: Vec<Window> = windows |
| 1511 |
|
- .iter() |
| 1512 |
|
- .filter(|&&w| self.floating_windows.contains(&w)) |
| 1513 |
|
- .copied() |
| 1514 |
|
- .collect(); |
| 1515 |
|
- |
| 1516 |
|
- for window in floating_windows { |
| 1517 |
|
- let monitor_idx = self |
| 1518 |
|
- .clients |
| 1519 |
|
- .get(&window) |
| 1520 |
|
- .map(|c| c.monitor_index) |
| 1521 |
|
- .unwrap_or(self.selected_monitor); |
| 1522 |
|
- let monitor = &self.monitors[monitor_idx]; |
| 1523 |
|
- |
| 1524 |
|
- let (outer_gap_h, outer_gap_v) = if self.gaps_enabled { |
| 1525 |
|
- ( |
| 1526 |
|
- self.config.gap_outer_horizontal, |
| 1527 |
|
- self.config.gap_outer_vertical, |
| 1528 |
|
- ) |
| 1529 |
|
- } else { |
| 1530 |
|
- (0, 0) |
| 1531 |
|
- }; |
| 1532 |
|
- |
| 1533 |
|
- let window_x = monitor.screen_x + outer_gap_h as i32; |
| 1534 |
|
- let window_y = monitor.screen_y + outer_gap_v as i32; |
| 1535 |
|
- let window_width = monitor |
| 1536 |
|
- .screen_width |
| 1537 |
|
- .saturating_sub(2 * outer_gap_h as i32) |
| 1538 |
|
- .saturating_sub(2 * border_width as i32); |
| 1539 |
|
- let window_height = monitor |
| 1540 |
|
- .screen_height |
| 1541 |
|
- .saturating_sub(2 * outer_gap_v as i32) |
| 1542 |
|
- .saturating_sub(2 * border_width as i32); |
| 1543 |
|
- |
| 1544 |
|
- self.connection.configure_window( |
| 1545 |
|
- window, |
| 1546 |
|
- &x11rb::protocol::xproto::ConfigureWindowAux::new() |
| 1547 |
|
- .x(window_x) |
| 1548 |
|
- .y(window_y) |
| 1549 |
|
- .width(window_width as u32) |
| 1550 |
|
- .height(window_height as u32), |
| 1551 |
|
- )?; |
| 1552 |
|
- } |
| 1553 |
|
- self.connection.flush()?; |
| 1554 |
|
- } else { |
| 1555 |
|
- let Some(focused_window) = self |
| 1556 |
|
- .monitors |
| 1557 |
|
- .get(self.selected_monitor) |
| 1558 |
|
- .and_then(|m| m.selected_client) |
| 1559 |
|
- else { |
| 1560 |
|
- return Ok(()); |
| 1561 |
|
- }; |
| 1562 |
|
- |
| 1563 |
|
- self.fullscreen_windows.remove(&focused_window); |
| 1564 |
|
- |
| 1565 |
|
- if let Some(last) = self.last_layout { |
| 1566 |
|
- if let Ok(layout) = layout_from_str(last) { |
| 1567 |
|
- self.layout = layout; |
| 1568 |
|
- } |
| 1569 |
|
- } |
| 1570 |
|
- |
| 1571 |
|
- let windows_to_restore: Vec<Window> = self |
| 1572 |
|
- .floating_geometry_before_fullscreen |
| 1573 |
|
- .keys() |
| 1574 |
|
- .copied() |
| 1575 |
|
- .collect(); |
| 1576 |
|
- |
| 1577 |
|
- for window in windows_to_restore { |
| 1578 |
|
- if let Some(&(x, y, width, height, border_width)) = |
| 1579 |
|
- self.floating_geometry_before_fullscreen.get(&window) |
| 1580 |
|
- { |
| 1581 |
|
- self.connection.configure_window( |
| 1582 |
|
- window, |
| 1583 |
|
- &ConfigureWindowAux::new() |
| 1584 |
|
- .x(x as i32) |
| 1585 |
|
- .y(y as i32) |
| 1586 |
|
- .width(width as u32) |
| 1587 |
|
- .height(height as u32) |
| 1588 |
|
- .border_width(border_width as u32), |
| 1589 |
|
- )?; |
| 1590 |
|
- |
| 1591 |
|
- if let Some(c) = self.clients.get_mut(&window) { |
| 1592 |
|
- c.x_position = x; |
| 1593 |
|
- c.y_position = y; |
| 1594 |
|
- c.width = width; |
| 1595 |
|
- c.height = height; |
| 1596 |
|
- c.border_width = border_width; |
| 1597 |
|
- } |
| 1598 |
|
- |
| 1599 |
|
- self.floating_geometry_before_fullscreen.remove(&window); |
| 1600 |
|
- } |
| 1601 |
|
- } |
| 1602 |
|
- self.connection.flush()?; |
| 1603 |
|
- |
| 1604 |
|
- self.toggle_bar()?; |
|
1449 |
+ let Some(focused_window) = self |
|
1450 |
+ .monitors |
|
1451 |
+ .get(self.selected_monitor) |
|
1452 |
+ .and_then(|m| m.selected_client) |
|
1453 |
+ else { |
|
1454 |
+ return Ok(()); |
|
1455 |
+ }; |
| 1605 |
1456 |
|
| 1606 |
|
- if self.layout.name() != "normie" { |
| 1607 |
|
- self.apply_layout()?; |
| 1608 |
|
- } else { |
| 1609 |
|
- if let Some(bar) = self.bars.get(self.selected_monitor) { |
| 1610 |
|
- self.connection.configure_window( |
| 1611 |
|
- bar.window(), |
| 1612 |
|
- &x11rb::protocol::xproto::ConfigureWindowAux::new() |
| 1613 |
|
- .stack_mode(x11rb::protocol::xproto::StackMode::ABOVE), |
| 1614 |
|
- )?; |
| 1615 |
|
- self.connection.flush()?; |
| 1616 |
|
- } |
| 1617 |
|
- } |
| 1618 |
|
- } |
|
1457 |
+ let is_fullscreen = self.fullscreen_windows.contains(&focused_window); |
|
1458 |
+ self.set_window_fullscreen(focused_window, !is_fullscreen)?; |
| 1619 |
1459 |
Ok(()) |
| 1620 |
1460 |
} |
| 1621 |
1461 |
|
|
|
@@ -1643,11 +1483,15 @@ impl WindowManager { |
| 1643 |
1483 |
client.is_fullscreen = true; |
| 1644 |
1484 |
client.old_state = client.is_floating; |
| 1645 |
1485 |
client.old_border_width = client.border_width; |
|
1486 |
+ client.old_x_position = client.x_position; |
|
1487 |
+ client.old_y_position = client.y_position; |
|
1488 |
+ client.old_width = client.width; |
|
1489 |
+ client.old_height = client.height; |
| 1646 |
1490 |
client.border_width = 0; |
| 1647 |
|
- client.is_floating = true; |
| 1648 |
1491 |
} |
| 1649 |
1492 |
|
| 1650 |
1493 |
self.fullscreen_windows.insert(window); |
|
1494 |
+ self.floating_windows.insert(window); |
| 1651 |
1495 |
|
| 1652 |
1496 |
self.connection.configure_window( |
| 1653 |
1497 |
window, |
|
|
@@ -1674,26 +1518,20 @@ impl WindowManager { |
| 1674 |
1518 |
|
| 1675 |
1519 |
self.fullscreen_windows.remove(&window); |
| 1676 |
1520 |
|
|
1521 |
+ let was_floating = self |
|
1522 |
+ .clients |
|
1523 |
+ .get(&window) |
|
1524 |
+ .map(|c| c.old_state) |
|
1525 |
+ .unwrap_or(false); |
|
1526 |
+ |
|
1527 |
+ if !was_floating { |
|
1528 |
+ self.floating_windows.remove(&window); |
|
1529 |
+ } |
|
1530 |
+ |
| 1677 |
1531 |
if let Some(client) = self.clients.get_mut(&window) { |
| 1678 |
1532 |
client.is_fullscreen = false; |
| 1679 |
1533 |
client.is_floating = client.old_state; |
| 1680 |
1534 |
client.border_width = client.old_border_width; |
| 1681 |
|
- |
| 1682 |
|
- let x = client.old_x_position; |
| 1683 |
|
- let y = client.old_y_position; |
| 1684 |
|
- let w = client.old_width; |
| 1685 |
|
- let h = client.old_height; |
| 1686 |
|
- let bw = client.border_width; |
| 1687 |
|
- |
| 1688 |
|
- self.connection.configure_window( |
| 1689 |
|
- window, |
| 1690 |
|
- &x11rb::protocol::xproto::ConfigureWindowAux::new() |
| 1691 |
|
- .x(x as i32) |
| 1692 |
|
- .y(y as i32) |
| 1693 |
|
- .width(w as u32) |
| 1694 |
|
- .height(h as u32) |
| 1695 |
|
- .border_width(bw as u32), |
| 1696 |
|
- )?; |
| 1697 |
1535 |
} |
| 1698 |
1536 |
|
| 1699 |
1537 |
self.apply_layout()?; |
|
|
@@ -1702,20 +1540,6 @@ impl WindowManager { |
| 1702 |
1540 |
Ok(()) |
| 1703 |
1541 |
} |
| 1704 |
1542 |
|
| 1705 |
|
- fn toggle_bar(&mut self) -> WmResult<()> { |
| 1706 |
|
- self.show_bar = !self.show_bar; |
| 1707 |
|
- if let Some(bar) = self.bars.get(self.selected_monitor) { |
| 1708 |
|
- if self.show_bar { |
| 1709 |
|
- self.connection.map_window(bar.window())?; |
| 1710 |
|
- } else { |
| 1711 |
|
- self.connection.unmap_window(bar.window())?; |
| 1712 |
|
- } |
| 1713 |
|
- self.connection.flush()?; |
| 1714 |
|
- } |
| 1715 |
|
- self.apply_layout()?; |
| 1716 |
|
- Ok(()) |
| 1717 |
|
- } |
| 1718 |
|
- |
| 1719 |
1543 |
fn get_transient_parent(&self, window: Window) -> Option<Window> { |
| 1720 |
1544 |
self.connection |
| 1721 |
1545 |
.get_property( |
|
|
@@ -1751,15 +1575,14 @@ impl WindowManager { |
| 1751 |
1575 |
.ok() |
| 1752 |
1576 |
.and_then(|cookie| cookie.reply().ok()); |
| 1753 |
1577 |
|
| 1754 |
|
- if let Some(reply) = reply { |
| 1755 |
|
- if !reply.value.is_empty() { |
| 1756 |
|
- if let Ok(text) = std::str::from_utf8(&reply.value) { |
| 1757 |
|
- let parts: Vec<&str> = text.split('\0').collect(); |
| 1758 |
|
- let instance = parts.get(0).unwrap_or(&"").to_string(); |
| 1759 |
|
- let class = parts.get(1).unwrap_or(&"").to_string(); |
| 1760 |
|
- return (instance, class); |
| 1761 |
|
- } |
| 1762 |
|
- } |
|
1578 |
+ if let Some(reply) = reply |
|
1579 |
+ && !reply.value.is_empty() |
|
1580 |
+ && let Ok(text) = std::str::from_utf8(&reply.value) |
|
1581 |
+ { |
|
1582 |
+ let parts: Vec<&str> = text.split('\0').collect(); |
|
1583 |
+ let instance = parts.first().unwrap_or(&"").to_string(); |
|
1584 |
+ let class = parts.get(1).unwrap_or(&"").to_string(); |
|
1585 |
+ return (instance, class); |
| 1763 |
1586 |
} |
| 1764 |
1587 |
|
| 1765 |
1588 |
(String::new(), String::new()) |
|
|
@@ -1801,10 +1624,10 @@ impl WindowManager { |
| 1801 |
1624 |
} |
| 1802 |
1625 |
} |
| 1803 |
1626 |
|
| 1804 |
|
- if let Some(monitor_index) = rule_monitor { |
| 1805 |
|
- if monitor_index < self.monitors.len() { |
| 1806 |
|
- client.monitor_index = monitor_index; |
| 1807 |
|
- } |
|
1627 |
+ if let Some(monitor_index) = rule_monitor |
|
1628 |
+ && monitor_index < self.monitors.len() |
|
1629 |
+ { |
|
1630 |
+ client.monitor_index = monitor_index; |
| 1808 |
1631 |
} |
| 1809 |
1632 |
|
| 1810 |
1633 |
let tags = rule_tags.unwrap_or_else(|| { |
|
|
@@ -1937,11 +1760,11 @@ impl WindowManager { |
| 1937 |
1760 |
.get(&window) |
| 1938 |
1761 |
.map(|c| c.is_fixed) |
| 1939 |
1762 |
.unwrap_or(false); |
| 1940 |
|
- if let Some(c) = self.clients.get_mut(&window) { |
| 1941 |
|
- if !c.is_floating { |
| 1942 |
|
- c.is_floating = is_transient || is_fixed; |
| 1943 |
|
- c.old_state = c.is_floating; |
| 1944 |
|
- } |
|
1763 |
+ if let Some(c) = self.clients.get_mut(&window) |
|
1764 |
+ && !c.is_floating |
|
1765 |
+ { |
|
1766 |
+ c.is_floating = is_transient || is_fixed; |
|
1767 |
+ c.old_state = c.is_floating; |
| 1945 |
1768 |
} |
| 1946 |
1769 |
|
| 1947 |
1770 |
if self |
|
|
@@ -1976,14 +1799,13 @@ impl WindowManager { |
| 1976 |
1799 |
let final_tags = self.clients.get(&window).map(|c| c.tags).unwrap_or(tags); |
| 1977 |
1800 |
let _ = self.save_client_tag(window, final_tags); |
| 1978 |
1801 |
|
| 1979 |
|
- if client_monitor == self.selected_monitor { |
| 1980 |
|
- if let Some(old_sel) = self |
|
1802 |
+ if client_monitor == self.selected_monitor |
|
1803 |
+ && let Some(old_sel) = self |
| 1981 |
1804 |
.monitors |
| 1982 |
1805 |
.get(self.selected_monitor) |
| 1983 |
1806 |
.and_then(|m| m.selected_client) |
| 1984 |
|
- { |
| 1985 |
|
- self.unfocus(old_sel)?; |
| 1986 |
|
- } |
|
1807 |
+ { |
|
1808 |
+ self.unfocus(old_sel)?; |
| 1987 |
1809 |
} |
| 1988 |
1810 |
|
| 1989 |
1811 |
if let Some(m) = self.monitors.get_mut(client_monitor) { |
|
|
@@ -2036,7 +1858,7 @@ impl WindowManager { |
| 2036 |
1858 |
self.connection.grab_button( |
| 2037 |
1859 |
false, |
| 2038 |
1860 |
window, |
| 2039 |
|
- EventMask::BUTTON_PRESS.into(), |
|
1861 |
+ EventMask::BUTTON_PRESS, |
| 2040 |
1862 |
GrabMode::SYNC, |
| 2041 |
1863 |
GrabMode::SYNC, |
| 2042 |
1864 |
x11rb::NONE, |
|
|
@@ -2052,10 +1874,10 @@ impl WindowManager { |
| 2052 |
1874 |
let monitor = self.monitors.get_mut(self.selected_monitor).unwrap(); |
| 2053 |
1875 |
let old_selected = monitor.selected_client; |
| 2054 |
1876 |
|
| 2055 |
|
- if let Some(old_win) = old_selected { |
| 2056 |
|
- if old_selected != window { |
| 2057 |
|
- self.unfocus(old_win)?; |
| 2058 |
|
- } |
|
1877 |
+ if let Some(old_win) = old_selected |
|
1878 |
+ && old_selected != window |
|
1879 |
+ { |
|
1880 |
+ self.unfocus(old_win)?; |
| 2059 |
1881 |
} |
| 2060 |
1882 |
|
| 2061 |
1883 |
let mut win = window; |
|
|
@@ -2079,6 +1901,10 @@ impl WindowManager { |
| 2079 |
1901 |
return Ok(()); |
| 2080 |
1902 |
} |
| 2081 |
1903 |
|
|
1904 |
+ if self.clients.get(&win).is_some_and(|c| c.is_urgent) { |
|
1905 |
+ self.set_urgent(win, false)?; |
|
1906 |
+ } |
|
1907 |
+ |
| 2082 |
1908 |
let monitor_idx = self |
| 2083 |
1909 |
.clients |
| 2084 |
1910 |
.get(&win) |
|
|
@@ -2132,18 +1958,19 @@ impl WindowManager { |
| 2132 |
1958 |
|
| 2133 |
1959 |
let mut windows_to_restack: Vec<Window> = Vec::new(); |
| 2134 |
1960 |
|
| 2135 |
|
- if let Some(selected) = monitor.selected_client { |
| 2136 |
|
- if self.floating_windows.contains(&selected) { |
| 2137 |
|
- windows_to_restack.push(selected); |
| 2138 |
|
- } |
|
1961 |
+ if let Some(selected) = monitor.selected_client |
|
1962 |
+ && self.floating_windows.contains(&selected) |
|
1963 |
+ { |
|
1964 |
+ windows_to_restack.push(selected); |
| 2139 |
1965 |
} |
| 2140 |
1966 |
|
| 2141 |
1967 |
let mut current = monitor.stack_head; |
| 2142 |
1968 |
while let Some(win) = current { |
| 2143 |
|
- if self.windows.contains(&win) && self.floating_windows.contains(&win) { |
| 2144 |
|
- if Some(win) != monitor.selected_client { |
| 2145 |
|
- windows_to_restack.push(win); |
| 2146 |
|
- } |
|
1969 |
+ if self.windows.contains(&win) |
|
1970 |
+ && self.floating_windows.contains(&win) |
|
1971 |
+ && Some(win) != monitor.selected_client |
|
1972 |
+ { |
|
1973 |
+ windows_to_restack.push(win); |
| 2147 |
1974 |
} |
| 2148 |
1975 |
current = self.clients.get(&win).and_then(|c| c.stack_next); |
| 2149 |
1976 |
} |
|
|
@@ -2214,12 +2041,10 @@ impl WindowManager { |
| 2214 |
2041 |
} else { |
| 2215 |
2042 |
stack_windows[0] |
| 2216 |
2043 |
} |
|
2044 |
+ } else if idx > 0 { |
|
2045 |
+ stack_windows[idx - 1] |
| 2217 |
2046 |
} else { |
| 2218 |
|
- if idx > 0 { |
| 2219 |
|
- stack_windows[idx - 1] |
| 2220 |
|
- } else { |
| 2221 |
|
- stack_windows[stack_windows.len() - 1] |
| 2222 |
|
- } |
|
2047 |
+ stack_windows[stack_windows.len() - 1] |
| 2223 |
2048 |
} |
| 2224 |
2049 |
} else { |
| 2225 |
2050 |
return Ok(()); |
|
|
@@ -2337,20 +2162,18 @@ impl WindowManager { |
| 2337 |
2162 |
client.next = temp; |
| 2338 |
2163 |
} |
| 2339 |
2164 |
|
| 2340 |
|
- if let Some(prev) = prev_selected { |
| 2341 |
|
- if prev != target { |
| 2342 |
|
- if let Some(client) = self.clients.get_mut(&prev) { |
| 2343 |
|
- client.next = Some(target); |
| 2344 |
|
- } |
| 2345 |
|
- } |
|
2165 |
+ if let Some(prev) = prev_selected |
|
2166 |
+ && prev != target |
|
2167 |
+ && let Some(client) = self.clients.get_mut(&prev) |
|
2168 |
+ { |
|
2169 |
+ client.next = Some(target); |
| 2346 |
2170 |
} |
| 2347 |
2171 |
|
| 2348 |
|
- if let Some(prev) = prev_target { |
| 2349 |
|
- if prev != selected { |
| 2350 |
|
- if let Some(client) = self.clients.get_mut(&prev) { |
| 2351 |
|
- client.next = Some(selected); |
| 2352 |
|
- } |
| 2353 |
|
- } |
|
2172 |
+ if let Some(prev) = prev_target |
|
2173 |
+ && prev != selected |
|
2174 |
+ && let Some(client) = self.clients.get_mut(&prev) |
|
2175 |
+ { |
|
2176 |
+ client.next = Some(selected); |
| 2354 |
2177 |
} |
| 2355 |
2178 |
|
| 2356 |
2179 |
if let Some(monitor) = self.monitors.get_mut(monitor_index) { |
|
|
@@ -2420,18 +2243,18 @@ impl WindowManager { |
| 2420 |
2243 |
old_focused: Option<Window>, |
| 2421 |
2244 |
new_focused: Window, |
| 2422 |
2245 |
) -> WmResult<()> { |
| 2423 |
|
- if let Some(old_win) = old_focused { |
| 2424 |
|
- if old_win != new_focused { |
| 2425 |
|
- self.connection.configure_window( |
| 2426 |
|
- old_win, |
| 2427 |
|
- &ConfigureWindowAux::new().border_width(self.config.border_width), |
| 2428 |
|
- )?; |
|
2246 |
+ if let Some(old_win) = old_focused |
|
2247 |
+ && old_win != new_focused |
|
2248 |
+ { |
|
2249 |
+ self.connection.configure_window( |
|
2250 |
+ old_win, |
|
2251 |
+ &ConfigureWindowAux::new().border_width(self.config.border_width), |
|
2252 |
+ )?; |
| 2429 |
2253 |
|
| 2430 |
|
- self.connection.change_window_attributes( |
| 2431 |
|
- old_win, |
| 2432 |
|
- &ChangeWindowAttributesAux::new().border_pixel(self.config.border_unfocused), |
| 2433 |
|
- )?; |
| 2434 |
|
- } |
|
2254 |
+ self.connection.change_window_attributes( |
|
2255 |
+ old_win, |
|
2256 |
+ &ChangeWindowAttributesAux::new().border_pixel(self.config.border_unfocused), |
|
2257 |
+ )?; |
| 2435 |
2258 |
} |
| 2436 |
2259 |
|
| 2437 |
2260 |
self.connection.configure_window( |
|
|
@@ -2490,8 +2313,7 @@ impl WindowManager { |
| 2490 |
2313 |
.grab_pointer( |
| 2491 |
2314 |
false, |
| 2492 |
2315 |
self.root, |
| 2493 |
|
- (EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE | EventMask::BUTTON_PRESS) |
| 2494 |
|
- .into(), |
|
2316 |
+ EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE | EventMask::BUTTON_PRESS, |
| 2495 |
2317 |
GrabMode::ASYNC, |
| 2496 |
2318 |
GrabMode::ASYNC, |
| 2497 |
2319 |
x11rb::NONE, |
|
|
@@ -2748,8 +2570,7 @@ impl WindowManager { |
| 2748 |
2570 |
.grab_pointer( |
| 2749 |
2571 |
false, |
| 2750 |
2572 |
self.root, |
| 2751 |
|
- (EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE | EventMask::BUTTON_PRESS) |
| 2752 |
|
- .into(), |
|
2573 |
+ EventMask::POINTER_MOTION | EventMask::BUTTON_RELEASE | EventMask::BUTTON_PRESS, |
| 2753 |
2574 |
GrabMode::ASYNC, |
| 2754 |
2575 |
GrabMode::ASYNC, |
| 2755 |
2576 |
x11rb::NONE, |
|
|
@@ -2784,29 +2605,27 @@ impl WindowManager { |
| 2784 |
2605 |
.map(|c| c.is_floating) |
| 2785 |
2606 |
.unwrap_or(false); |
| 2786 |
2607 |
|
| 2787 |
|
- if should_resize { |
| 2788 |
|
- if let Some(client) = self.clients.get(&window).cloned() { |
| 2789 |
|
- let (_, _, hint_width, hint_height, _) = self.apply_size_hints( |
| 2790 |
|
- window, |
| 2791 |
|
- client.x_position as i32, |
| 2792 |
|
- client.y_position as i32, |
| 2793 |
|
- new_width as i32, |
| 2794 |
|
- new_height as i32, |
| 2795 |
|
- ); |
| 2796 |
|
- |
| 2797 |
|
- if let Some(client_mut) = self.clients.get_mut(&window) { |
| 2798 |
|
- client_mut.width = hint_width as u16; |
| 2799 |
|
- client_mut.height = hint_height as u16; |
| 2800 |
|
- } |
| 2801 |
|
- |
| 2802 |
|
- self.connection.configure_window( |
| 2803 |
|
- window, |
| 2804 |
|
- &ConfigureWindowAux::new() |
| 2805 |
|
- .width(hint_width as u32) |
| 2806 |
|
- .height(hint_height as u32), |
| 2807 |
|
- )?; |
| 2808 |
|
- self.connection.flush()?; |
|
2608 |
+ if should_resize && let Some(client) = self.clients.get(&window).cloned() { |
|
2609 |
+ let (_, _, hint_width, hint_height, _) = self.apply_size_hints( |
|
2610 |
+ window, |
|
2611 |
+ client.x_position as i32, |
|
2612 |
+ client.y_position as i32, |
|
2613 |
+ new_width as i32, |
|
2614 |
+ new_height as i32, |
|
2615 |
+ ); |
|
2616 |
+ |
|
2617 |
+ if let Some(client_mut) = self.clients.get_mut(&window) { |
|
2618 |
+ client_mut.width = hint_width as u16; |
|
2619 |
+ client_mut.height = hint_height as u16; |
| 2809 |
2620 |
} |
|
2621 |
+ |
|
2622 |
+ self.connection.configure_window( |
|
2623 |
+ window, |
|
2624 |
+ &ConfigureWindowAux::new() |
|
2625 |
+ .width(hint_width as u32) |
|
2626 |
+ .height(hint_height as u32), |
|
2627 |
+ )?; |
|
2628 |
+ self.connection.flush()?; |
| 2810 |
2629 |
} |
| 2811 |
2630 |
} |
| 2812 |
2631 |
Event::ButtonRelease(_) => break, |
|
|
@@ -2861,26 +2680,26 @@ impl WindowManager { |
| 2861 |
2680 |
fn handle_event(&mut self, event: Event) -> WmResult<Option<bool>> { |
| 2862 |
2681 |
match event { |
| 2863 |
2682 |
Event::KeyPress(ref key_event) if key_event.event == self.overlay.window() => { |
| 2864 |
|
- if self.overlay.is_visible() { |
| 2865 |
|
- if let Err(error) = self.overlay.hide(&self.connection) { |
| 2866 |
|
- eprintln!("Failed to hide overlay: {:?}", error); |
| 2867 |
|
- } |
|
2683 |
+ if self.overlay.is_visible() |
|
2684 |
+ && let Err(error) = self.overlay.hide(&self.connection) |
|
2685 |
+ { |
|
2686 |
+ eprintln!("Failed to hide overlay: {:?}", error); |
| 2868 |
2687 |
} |
| 2869 |
2688 |
return Ok(None); |
| 2870 |
2689 |
} |
| 2871 |
2690 |
Event::ButtonPress(ref button_event) if button_event.event == self.overlay.window() => { |
| 2872 |
|
- if self.overlay.is_visible() { |
| 2873 |
|
- if let Err(error) = self.overlay.hide(&self.connection) { |
| 2874 |
|
- eprintln!("Failed to hide overlay: {:?}", error); |
| 2875 |
|
- } |
|
2691 |
+ if self.overlay.is_visible() |
|
2692 |
+ && let Err(error) = self.overlay.hide(&self.connection) |
|
2693 |
+ { |
|
2694 |
+ eprintln!("Failed to hide overlay: {:?}", error); |
| 2876 |
2695 |
} |
| 2877 |
2696 |
return Ok(None); |
| 2878 |
2697 |
} |
| 2879 |
2698 |
Event::Expose(ref expose_event) if expose_event.window == self.overlay.window() => { |
| 2880 |
|
- if self.overlay.is_visible() { |
| 2881 |
|
- if let Err(error) = self.overlay.draw(&self.connection, &self.font) { |
| 2882 |
|
- eprintln!("Failed to draw overlay: {:?}", error); |
| 2883 |
|
- } |
|
2699 |
+ if self.overlay.is_visible() |
|
2700 |
+ && let Err(error) = self.overlay.draw(&self.connection, &self.font) |
|
2701 |
+ { |
|
2702 |
+ eprintln!("Failed to draw overlay: {:?}", error); |
| 2884 |
2703 |
} |
| 2885 |
2704 |
return Ok(None); |
| 2886 |
2705 |
} |
|
|
@@ -2893,10 +2712,10 @@ impl WindowManager { |
| 2893 |
2712 |
let keysym = mapping.keycode_to_keysym(e.detail); |
| 2894 |
2713 |
let is_escape = keysym == keysyms::XK_ESCAPE; |
| 2895 |
2714 |
let is_q = keysym == keysyms::XK_Q || keysym == 0x0051; |
| 2896 |
|
- if is_escape || is_q { |
| 2897 |
|
- if let Err(error) = self.keybind_overlay.hide(&self.connection) { |
| 2898 |
|
- eprintln!("Failed to hide keybind overlay: {:?}", error); |
| 2899 |
|
- } |
|
2715 |
+ if (is_escape || is_q) |
|
2716 |
+ && let Err(error) = self.keybind_overlay.hide(&self.connection) |
|
2717 |
+ { |
|
2718 |
+ eprintln!("Failed to hide keybind overlay: {:?}", error); |
| 2900 |
2719 |
} |
| 2901 |
2720 |
} |
| 2902 |
2721 |
} |
|
|
@@ -2910,10 +2729,10 @@ impl WindowManager { |
| 2910 |
2729 |
Event::Expose(ref expose_event) |
| 2911 |
2730 |
if expose_event.window == self.keybind_overlay.window() => |
| 2912 |
2731 |
{ |
| 2913 |
|
- if self.keybind_overlay.is_visible() { |
| 2914 |
|
- if let Err(error) = self.keybind_overlay.draw(&self.connection, &self.font) { |
| 2915 |
|
- eprintln!("Failed to draw keybind overlay: {:?}", error); |
| 2916 |
|
- } |
|
2732 |
+ if self.keybind_overlay.is_visible() |
|
2733 |
+ && let Err(error) = self.keybind_overlay.draw(&self.connection, &self.font) |
|
2734 |
+ { |
|
2735 |
+ eprintln!("Failed to draw keybind overlay: {:?}", error); |
| 2917 |
2736 |
} |
| 2918 |
2737 |
return Ok(None); |
| 2919 |
2738 |
} |
|
|
@@ -2956,16 +2775,15 @@ impl WindowManager { |
| 2956 |
2775 |
.get(&event.window) |
| 2957 |
2776 |
.map(|c| c.is_floating) |
| 2958 |
2777 |
.unwrap_or(false); |
| 2959 |
|
- if !is_floating { |
| 2960 |
|
- if let Some(parent) = self.get_transient_parent(event.window) { |
| 2961 |
|
- if self.clients.contains_key(&parent) { |
| 2962 |
|
- if let Some(c) = self.clients.get_mut(&event.window) { |
| 2963 |
|
- c.is_floating = true; |
| 2964 |
|
- } |
| 2965 |
|
- self.floating_windows.insert(event.window); |
| 2966 |
|
- self.apply_layout()?; |
| 2967 |
|
- } |
|
2778 |
+ if !is_floating |
|
2779 |
+ && let Some(parent) = self.get_transient_parent(event.window) |
|
2780 |
+ && self.clients.contains_key(&parent) |
|
2781 |
+ { |
|
2782 |
+ if let Some(c) = self.clients.get_mut(&event.window) { |
|
2783 |
+ c.is_floating = true; |
| 2968 |
2784 |
} |
|
2785 |
+ self.floating_windows.insert(event.window); |
|
2786 |
+ self.apply_layout()?; |
| 2969 |
2787 |
} |
| 2970 |
2788 |
} else if event.atom == AtomEnum::WM_NORMAL_HINTS.into() { |
| 2971 |
2789 |
if let Some(c) = self.clients.get_mut(&event.window) { |
|
|
@@ -2992,11 +2810,11 @@ impl WindowManager { |
| 2992 |
2810 |
return Ok(None); |
| 2993 |
2811 |
} |
| 2994 |
2812 |
if self.windows.contains(&event.event) { |
| 2995 |
|
- if let Some(client) = self.clients.get(&event.event) { |
| 2996 |
|
- if client.monitor_index != self.selected_monitor { |
| 2997 |
|
- self.selected_monitor = client.monitor_index; |
| 2998 |
|
- self.update_bar()?; |
| 2999 |
|
- } |
|
2813 |
+ if let Some(client) = self.clients.get(&event.event) |
|
2814 |
+ && client.monitor_index != self.selected_monitor |
|
2815 |
+ { |
|
2816 |
+ self.selected_monitor = client.monitor_index; |
|
2817 |
+ self.update_bar()?; |
| 3000 |
2818 |
} |
| 3001 |
2819 |
self.focus(Some(event.event))?; |
| 3002 |
2820 |
self.update_tab_bars()?; |
|
|
@@ -3009,16 +2827,15 @@ impl WindowManager { |
| 3009 |
2827 |
|
| 3010 |
2828 |
if let Some(monitor_index) = |
| 3011 |
2829 |
self.get_monitor_at_point(event.root_x as i32, event.root_y as i32) |
|
2830 |
+ && monitor_index != self.selected_monitor |
| 3012 |
2831 |
{ |
| 3013 |
|
- if monitor_index != self.selected_monitor { |
| 3014 |
|
- self.selected_monitor = monitor_index; |
| 3015 |
|
- self.update_bar()?; |
|
2832 |
+ self.selected_monitor = monitor_index; |
|
2833 |
+ self.update_bar()?; |
| 3016 |
2834 |
|
| 3017 |
|
- let visible = self.visible_windows_on_monitor(monitor_index); |
| 3018 |
|
- if let Some(&win) = visible.first() { |
| 3019 |
|
- self.focus(Some(win))?; |
| 3020 |
|
- self.update_tab_bars()?; |
| 3021 |
|
- } |
|
2835 |
+ let visible = self.visible_windows_on_monitor(monitor_index); |
|
2836 |
+ if let Some(&win) = visible.first() { |
|
2837 |
+ self.focus(Some(win))?; |
|
2838 |
+ self.update_tab_bars()?; |
| 3022 |
2839 |
} |
| 3023 |
2840 |
} |
| 3024 |
2841 |
} |
|
|
@@ -3100,11 +2917,11 @@ impl WindowManager { |
| 3100 |
2917 |
} |
| 3101 |
2918 |
} |
| 3102 |
2919 |
Event::ButtonPress(event) => { |
| 3103 |
|
- if self.keybind_overlay.is_visible() && event.event != self.keybind_overlay.window() |
|
2920 |
+ if self.keybind_overlay.is_visible() |
|
2921 |
+ && event.event != self.keybind_overlay.window() |
|
2922 |
+ && let Err(error) = self.keybind_overlay.hide(&self.connection) |
| 3104 |
2923 |
{ |
| 3105 |
|
- if let Err(error) = self.keybind_overlay.hide(&self.connection) { |
| 3106 |
|
- eprintln!("Failed to hide keybind overlay: {:?}", error); |
| 3107 |
|
- } |
|
2924 |
+ eprintln!("Failed to hide keybind overlay: {:?}", error); |
| 3108 |
2925 |
} |
| 3109 |
2926 |
|
| 3110 |
2927 |
let is_bar_click = self |
|
|
@@ -3278,14 +3095,13 @@ impl WindowManager { |
| 3278 |
3095 |
let width_with_border = w + 2 * bw; |
| 3279 |
3096 |
let height_with_border = h + 2 * bw; |
| 3280 |
3097 |
|
| 3281 |
|
- if (x + w) > monitor.screen_x + monitor.screen_width as i32 && is_floating { |
|
3098 |
+ if (x + w) > monitor.screen_x + monitor.screen_width && is_floating { |
| 3282 |
3099 |
x = monitor.screen_x |
| 3283 |
|
- + (monitor.screen_width as i32 / 2 - width_with_border / 2); |
|
3100 |
+ + (monitor.screen_width / 2 - width_with_border / 2); |
| 3284 |
3101 |
} |
| 3285 |
|
- if (y + h) > monitor.screen_y + monitor.screen_height as i32 && is_floating |
| 3286 |
|
- { |
|
3102 |
+ if (y + h) > monitor.screen_y + monitor.screen_height && is_floating { |
| 3287 |
3103 |
y = monitor.screen_y |
| 3288 |
|
- + (monitor.screen_height as i32 / 2 - height_with_border / 2); |
|
3104 |
+ + (monitor.screen_height / 2 - height_with_border / 2); |
| 3289 |
3105 |
} |
| 3290 |
3106 |
|
| 3291 |
3107 |
if let Some(c) = self.clients.get_mut(&event.window) { |
|
|
@@ -3349,17 +3165,17 @@ impl WindowManager { |
| 3349 |
3165 |
} |
| 3350 |
3166 |
|
| 3351 |
3167 |
if event.type_ == self.atoms.net_wm_state { |
| 3352 |
|
- if let Some(data) = event.data.as_data32().get(1) { |
| 3353 |
|
- if *data == self.atoms.net_wm_state_fullscreen { |
| 3354 |
|
- let action = event.data.as_data32()[0]; |
| 3355 |
|
- let fullscreen = match action { |
| 3356 |
|
- 1 => true, |
| 3357 |
|
- 0 => false, |
| 3358 |
|
- 2 => !self.fullscreen_windows.contains(&event.window), |
| 3359 |
|
- _ => return Ok(None), |
| 3360 |
|
- }; |
| 3361 |
|
- self.set_window_fullscreen(event.window, fullscreen)?; |
| 3362 |
|
- } |
|
3168 |
+ if let Some(data) = event.data.as_data32().get(1) |
|
3169 |
+ && *data == self.atoms.net_wm_state_fullscreen |
|
3170 |
+ { |
|
3171 |
+ let action = event.data.as_data32()[0]; |
|
3172 |
+ let fullscreen = match action { |
|
3173 |
+ 1 => true, |
|
3174 |
+ 0 => false, |
|
3175 |
+ 2 => !self.fullscreen_windows.contains(&event.window), |
|
3176 |
+ _ => return Ok(None), |
|
3177 |
+ }; |
|
3178 |
+ self.set_window_fullscreen(event.window, fullscreen)?; |
| 3363 |
3179 |
} |
| 3364 |
3180 |
} else if event.type_ == self.atoms.net_active_window { |
| 3365 |
3181 |
let selected_window = self |
|
|
@@ -3384,10 +3200,10 @@ impl WindowManager { |
| 3384 |
3200 |
.get(self.selected_monitor) |
| 3385 |
3201 |
.and_then(|m| m.selected_client); |
| 3386 |
3202 |
|
| 3387 |
|
- if let Some(sel_win) = selected_window { |
| 3388 |
|
- if event.event != sel_win { |
| 3389 |
|
- self.set_focus(sel_win)?; |
| 3390 |
|
- } |
|
3203 |
+ if let Some(sel_win) = selected_window |
|
3204 |
+ && event.event != sel_win |
|
3205 |
+ { |
|
3206 |
+ self.set_focus(sel_win)?; |
| 3391 |
3207 |
} |
| 3392 |
3208 |
} |
| 3393 |
3209 |
Event::MappingNotify(event) => { |
|
|
@@ -3484,18 +3300,18 @@ impl WindowManager { |
| 3484 |
3300 |
let mut adjusted_width = geometry.width.saturating_sub(2 * border_width); |
| 3485 |
3301 |
let mut adjusted_height = geometry.height.saturating_sub(2 * border_width); |
| 3486 |
3302 |
|
| 3487 |
|
- if let Some(client) = self.clients.get(window).cloned() { |
| 3488 |
|
- if !client.is_floating { |
| 3489 |
|
- let (_, _, hint_width, hint_height, _) = self.apply_size_hints( |
| 3490 |
|
- *window, |
| 3491 |
|
- geometry.x_coordinate as i32, |
| 3492 |
|
- geometry.y_coordinate as i32, |
| 3493 |
|
- adjusted_width as i32, |
| 3494 |
|
- adjusted_height as i32, |
| 3495 |
|
- ); |
| 3496 |
|
- adjusted_width = hint_width as u32; |
| 3497 |
|
- adjusted_height = hint_height as u32; |
| 3498 |
|
- } |
|
3303 |
+ if let Some(client) = self.clients.get(window).cloned() |
|
3304 |
+ && !client.is_floating |
|
3305 |
+ { |
|
3306 |
+ let (_, _, hint_width, hint_height, _) = self.apply_size_hints( |
|
3307 |
+ *window, |
|
3308 |
+ geometry.x_coordinate, |
|
3309 |
+ geometry.y_coordinate, |
|
3310 |
+ adjusted_width as i32, |
|
3311 |
+ adjusted_height as i32, |
|
3312 |
+ ); |
|
3313 |
+ adjusted_width = hint_width as u32; |
|
3314 |
+ adjusted_height = hint_height as u32; |
| 3499 |
3315 |
} |
| 3500 |
3316 |
|
| 3501 |
3317 |
let adjusted_x = geometry.x_coordinate + monitor_x; |
|
|
@@ -3534,6 +3350,44 @@ impl WindowManager { |
| 3534 |
3350 |
self.showhide(stack_head)?; |
| 3535 |
3351 |
} |
| 3536 |
3352 |
|
|
3353 |
+ for monitor_index in 0..self.monitors.len() { |
|
3354 |
+ let monitor = &self.monitors[monitor_index]; |
|
3355 |
+ let tags = monitor.tagset[monitor.selected_tags_index]; |
|
3356 |
+ |
|
3357 |
+ let has_visible_fullscreen = self.fullscreen_windows.iter().any(|&w| { |
|
3358 |
+ self.clients.get(&w).map_or(false, |c| { |
|
3359 |
+ c.monitor_index == monitor_index && (c.tags & tags) != 0 |
|
3360 |
+ }) |
|
3361 |
+ }); |
|
3362 |
+ |
|
3363 |
+ if has_visible_fullscreen { |
|
3364 |
+ if let Some(bar) = self.bars.get(monitor_index) { |
|
3365 |
+ self.connection.unmap_window(bar.window())?; |
|
3366 |
+ } |
|
3367 |
+ |
|
3368 |
+ for &window in &self.fullscreen_windows { |
|
3369 |
+ if let Some(client) = self.clients.get(&window) { |
|
3370 |
+ if client.monitor_index == monitor_index && (client.tags & tags) != 0 { |
|
3371 |
+ self.connection.configure_window( |
|
3372 |
+ window, |
|
3373 |
+ &ConfigureWindowAux::new() |
|
3374 |
+ .border_width(0) |
|
3375 |
+ .x(monitor.screen_x) |
|
3376 |
+ .y(monitor.screen_y) |
|
3377 |
+ .width(monitor.screen_width as u32) |
|
3378 |
+ .height(monitor.screen_height as u32) |
|
3379 |
+ .stack_mode(StackMode::ABOVE), |
|
3380 |
+ )?; |
|
3381 |
+ } |
|
3382 |
+ } |
|
3383 |
+ } |
|
3384 |
+ } else if self.show_bar { |
|
3385 |
+ if let Some(bar) = self.bars.get(monitor_index) { |
|
3386 |
+ self.connection.map_window(bar.window())?; |
|
3387 |
+ } |
|
3388 |
+ } |
|
3389 |
+ } |
|
3390 |
+ |
| 3537 |
3391 |
self.connection.flush()?; |
| 3538 |
3392 |
|
| 3539 |
3393 |
let is_tabbed = self.layout.name() == LayoutType::Tabbed.as_str(); |
|
|
@@ -3601,10 +3455,8 @@ impl WindowManager { |
| 3601 |
3455 |
if let Err(e) = self.tab_bars[monitor_index].show(&self.connection) { |
| 3602 |
3456 |
eprintln!("Failed to show tab bar: {:?}", e); |
| 3603 |
3457 |
} |
| 3604 |
|
- } else { |
| 3605 |
|
- if let Err(e) = self.tab_bars[monitor_index].hide(&self.connection) { |
| 3606 |
|
- eprintln!("Failed to hide tab bar: {:?}", e); |
| 3607 |
|
- } |
|
3458 |
+ } else if let Err(e) = self.tab_bars[monitor_index].hide(&self.connection) { |
|
3459 |
+ eprintln!("Failed to hide tab bar: {:?}", e); |
| 3608 |
3460 |
} |
| 3609 |
3461 |
} |
| 3610 |
3462 |
|
|
|
@@ -3765,15 +3617,13 @@ impl WindowManager { |
| 3765 |
3617 |
.ok() |
| 3766 |
3618 |
.and_then(|cookie| cookie.reply().ok()); |
| 3767 |
3619 |
|
| 3768 |
|
- if let Some(name) = net_name { |
| 3769 |
|
- if !name.value.is_empty() { |
| 3770 |
|
- if let Ok(title) = String::from_utf8(name.value.clone()) { |
| 3771 |
|
- if let Some(client) = self.clients.get_mut(&window) { |
| 3772 |
|
- client.name = title; |
| 3773 |
|
- return Ok(()); |
| 3774 |
|
- } |
| 3775 |
|
- } |
| 3776 |
|
- } |
|
3620 |
+ if let Some(name) = net_name |
|
3621 |
+ && !name.value.is_empty() |
|
3622 |
+ && let Ok(title) = String::from_utf8(name.value.clone()) |
|
3623 |
+ && let Some(client) = self.clients.get_mut(&window) |
|
3624 |
+ { |
|
3625 |
+ client.name = title; |
|
3626 |
+ return Ok(()); |
| 3777 |
3627 |
} |
| 3778 |
3628 |
|
| 3779 |
3629 |
let wm_name = self |
|
|
@@ -3788,12 +3638,11 @@ impl WindowManager { |
| 3788 |
3638 |
)? |
| 3789 |
3639 |
.reply()?; |
| 3790 |
3640 |
|
| 3791 |
|
- if !wm_name.value.is_empty() { |
| 3792 |
|
- if let Ok(title) = String::from_utf8(wm_name.value.clone()) { |
| 3793 |
|
- if let Some(client) = self.clients.get_mut(&window) { |
| 3794 |
|
- client.name = title; |
| 3795 |
|
- } |
| 3796 |
|
- } |
|
3641 |
+ if !wm_name.value.is_empty() |
|
3642 |
+ && let Ok(title) = String::from_utf8(wm_name.value.clone()) |
|
3643 |
+ && let Some(client) = self.clients.get_mut(&window) |
|
3644 |
+ { |
|
3645 |
+ client.name = title; |
| 3797 |
3646 |
} |
| 3798 |
3647 |
|
| 3799 |
3648 |
Ok(()) |
|
|
@@ -3805,56 +3654,52 @@ impl WindowManager { |
| 3805 |
3654 |
.get_property(false, window, AtomEnum::WM_HINTS, AtomEnum::WM_HINTS, 0, 9)? |
| 3806 |
3655 |
.reply(); |
| 3807 |
3656 |
|
| 3808 |
|
- if let Ok(hints) = hints_reply { |
| 3809 |
|
- if hints.value.len() >= 4 { |
| 3810 |
|
- let flags = u32::from_ne_bytes([ |
| 3811 |
|
- hints.value[0], |
| 3812 |
|
- hints.value[1], |
| 3813 |
|
- hints.value[2], |
| 3814 |
|
- hints.value[3], |
| 3815 |
|
- ]); |
| 3816 |
|
- |
| 3817 |
|
- let selected_window = self |
| 3818 |
|
- .monitors |
| 3819 |
|
- .get(self.selected_monitor) |
| 3820 |
|
- .and_then(|m| m.selected_client); |
|
3657 |
+ if let Ok(hints) = hints_reply |
|
3658 |
+ && hints.value.len() >= 4 |
|
3659 |
+ { |
|
3660 |
+ let flags = u32::from_ne_bytes([ |
|
3661 |
+ hints.value[0], |
|
3662 |
+ hints.value[1], |
|
3663 |
+ hints.value[2], |
|
3664 |
+ hints.value[3], |
|
3665 |
+ ]); |
|
3666 |
+ |
|
3667 |
+ let selected_window = self |
|
3668 |
+ .monitors |
|
3669 |
+ .get(self.selected_monitor) |
|
3670 |
+ .and_then(|m| m.selected_client); |
| 3821 |
3671 |
|
| 3822 |
|
- if Some(window) == selected_window && (flags & 256) != 0 { |
| 3823 |
|
- let new_flags = flags & !256; |
| 3824 |
|
- let mut new_hints = hints.value.clone(); |
| 3825 |
|
- new_hints[0..4].copy_from_slice(&new_flags.to_ne_bytes()); |
|
3672 |
+ if Some(window) == selected_window && (flags & 256) != 0 { |
|
3673 |
+ let new_flags = flags & !256; |
|
3674 |
+ let mut new_hints = hints.value.clone(); |
|
3675 |
+ new_hints[0..4].copy_from_slice(&new_flags.to_ne_bytes()); |
| 3826 |
3676 |
|
| 3827 |
|
- self.connection.change_property( |
| 3828 |
|
- x11rb::protocol::xproto::PropMode::REPLACE, |
| 3829 |
|
- window, |
| 3830 |
|
- AtomEnum::WM_HINTS, |
| 3831 |
|
- AtomEnum::WM_HINTS, |
| 3832 |
|
- 32, |
| 3833 |
|
- 9, |
| 3834 |
|
- &new_hints, |
| 3835 |
|
- )?; |
| 3836 |
|
- } else { |
| 3837 |
|
- if let Some(client) = self.clients.get_mut(&window) { |
| 3838 |
|
- client.is_urgent = (flags & 256) != 0; |
| 3839 |
|
- } |
| 3840 |
|
- } |
|
3677 |
+ self.connection.change_property( |
|
3678 |
+ x11rb::protocol::xproto::PropMode::REPLACE, |
|
3679 |
+ window, |
|
3680 |
+ AtomEnum::WM_HINTS, |
|
3681 |
+ AtomEnum::WM_HINTS, |
|
3682 |
+ 32, |
|
3683 |
+ 9, |
|
3684 |
+ &new_hints, |
|
3685 |
+ )?; |
|
3686 |
+ } else if let Some(client) = self.clients.get_mut(&window) { |
|
3687 |
+ client.is_urgent = (flags & 256) != 0; |
|
3688 |
+ } |
| 3841 |
3689 |
|
| 3842 |
|
- if hints.value.len() >= 8 && (flags & 1) != 0 { |
| 3843 |
|
- let input = i32::from_ne_bytes([ |
| 3844 |
|
- hints.value[4], |
| 3845 |
|
- hints.value[5], |
| 3846 |
|
- hints.value[6], |
| 3847 |
|
- hints.value[7], |
| 3848 |
|
- ]); |
|
3690 |
+ if hints.value.len() >= 8 && (flags & 1) != 0 { |
|
3691 |
+ let input = i32::from_ne_bytes([ |
|
3692 |
+ hints.value[4], |
|
3693 |
+ hints.value[5], |
|
3694 |
+ hints.value[6], |
|
3695 |
+ hints.value[7], |
|
3696 |
+ ]); |
| 3849 |
3697 |
|
| 3850 |
|
- if let Some(client) = self.clients.get_mut(&window) { |
| 3851 |
|
- client.never_focus = input == 0; |
| 3852 |
|
- } |
| 3853 |
|
- } else { |
| 3854 |
|
- if let Some(client) = self.clients.get_mut(&window) { |
| 3855 |
|
- client.never_focus = false; |
| 3856 |
|
- } |
|
3698 |
+ if let Some(client) = self.clients.get_mut(&window) { |
|
3699 |
+ client.never_focus = input == 0; |
| 3857 |
3700 |
} |
|
3701 |
+ } else if let Some(client) = self.clients.get_mut(&window) { |
|
3702 |
+ client.never_focus = false; |
| 3858 |
3703 |
} |
| 3859 |
3704 |
} |
| 3860 |
3705 |
|
|
|
@@ -3863,21 +3708,19 @@ impl WindowManager { |
| 3863 |
3708 |
|
| 3864 |
3709 |
fn update_window_type(&mut self, window: Window) -> WmResult<()> { |
| 3865 |
3710 |
if let Ok(Some(state_atom)) = self.get_window_atom_property(window, self.atoms.net_wm_state) |
|
3711 |
+ && state_atom == self.atoms.net_wm_state_fullscreen |
| 3866 |
3712 |
{ |
| 3867 |
|
- if state_atom == self.atoms.net_wm_state_fullscreen { |
| 3868 |
|
- self.set_window_fullscreen(window, true)?; |
| 3869 |
|
- } |
|
3713 |
+ self.set_window_fullscreen(window, true)?; |
| 3870 |
3714 |
} |
| 3871 |
3715 |
|
| 3872 |
3716 |
if let Ok(Some(type_atom)) = |
| 3873 |
3717 |
self.get_window_atom_property(window, self.atoms.net_wm_window_type) |
|
3718 |
+ && type_atom == self.atoms.net_wm_window_type_dialog |
| 3874 |
3719 |
{ |
| 3875 |
|
- if type_atom == self.atoms.net_wm_window_type_dialog { |
| 3876 |
|
- if let Some(client) = self.clients.get_mut(&window) { |
| 3877 |
|
- client.is_floating = true; |
| 3878 |
|
- } |
| 3879 |
|
- self.floating_windows.insert(window); |
|
3720 |
+ if let Some(client) = self.clients.get_mut(&window) { |
|
3721 |
+ client.is_floating = true; |
| 3880 |
3722 |
} |
|
3723 |
+ self.floating_windows.insert(window); |
| 3881 |
3724 |
} |
| 3882 |
3725 |
|
| 3883 |
3726 |
Ok(()) |
|
|
@@ -4060,11 +3903,11 @@ impl WindowManager { |
| 4060 |
3903 |
} |
| 4061 |
3904 |
|
| 4062 |
3905 |
fn attach(&mut self, window: Window, monitor_index: usize) { |
| 4063 |
|
- if let Some(monitor) = self.monitors.get_mut(monitor_index) { |
| 4064 |
|
- if let Some(client) = self.clients.get_mut(&window) { |
| 4065 |
|
- client.next = monitor.clients_head; |
| 4066 |
|
- monitor.clients_head = Some(window); |
| 4067 |
|
- } |
|
3906 |
+ if let Some(monitor) = self.monitors.get_mut(monitor_index) |
|
3907 |
+ && let Some(client) = self.clients.get_mut(&window) |
|
3908 |
+ { |
|
3909 |
+ client.next = monitor.clients_head; |
|
3910 |
+ monitor.clients_head = Some(window); |
| 4068 |
3911 |
} |
| 4069 |
3912 |
} |
| 4070 |
3913 |
|
|
|
@@ -4082,44 +3925,43 @@ impl WindowManager { |
| 4082 |
3925 |
return; |
| 4083 |
3926 |
} |
| 4084 |
3927 |
|
| 4085 |
|
- if let Some(insert_after_window) = first_tagged { |
| 4086 |
|
- if let Some(after_client) = self.clients.get(&insert_after_window) { |
| 4087 |
|
- let old_next = after_client.next; |
| 4088 |
|
- if let Some(new_client) = self.clients.get_mut(&window) { |
| 4089 |
|
- new_client.next = old_next; |
| 4090 |
|
- } |
| 4091 |
|
- if let Some(after_client_mut) = self.clients.get_mut(&insert_after_window) { |
| 4092 |
|
- after_client_mut.next = Some(window); |
| 4093 |
|
- } |
|
3928 |
+ if let Some(insert_after_window) = first_tagged |
|
3929 |
+ && let Some(after_client) = self.clients.get(&insert_after_window) |
|
3930 |
+ { |
|
3931 |
+ let old_next = after_client.next; |
|
3932 |
+ if let Some(new_client) = self.clients.get_mut(&window) { |
|
3933 |
+ new_client.next = old_next; |
|
3934 |
+ } |
|
3935 |
+ if let Some(after_client_mut) = self.clients.get_mut(&insert_after_window) { |
|
3936 |
+ after_client_mut.next = Some(window); |
| 4094 |
3937 |
} |
| 4095 |
3938 |
} |
| 4096 |
3939 |
} |
| 4097 |
3940 |
|
| 4098 |
3941 |
fn detach(&mut self, window: Window) { |
| 4099 |
3942 |
let monitor_index = self.clients.get(&window).map(|c| c.monitor_index); |
| 4100 |
|
- if let Some(monitor_index) = monitor_index { |
| 4101 |
|
- if let Some(monitor) = self.monitors.get_mut(monitor_index) { |
| 4102 |
|
- if monitor.clients_head == Some(window) { |
| 4103 |
|
- if let Some(client) = self.clients.get(&window) { |
| 4104 |
|
- monitor.clients_head = client.next; |
| 4105 |
|
- } |
| 4106 |
|
- } else { |
| 4107 |
|
- let mut current = monitor.clients_head; |
| 4108 |
|
- while let Some(current_window) = current { |
| 4109 |
|
- if let Some(current_client) = self.clients.get(¤t_window) { |
| 4110 |
|
- if current_client.next == Some(window) { |
| 4111 |
|
- let new_next = self.clients.get(&window).and_then(|c| c.next); |
| 4112 |
|
- if let Some(current_client_mut) = |
| 4113 |
|
- self.clients.get_mut(¤t_window) |
| 4114 |
|
- { |
| 4115 |
|
- current_client_mut.next = new_next; |
| 4116 |
|
- } |
| 4117 |
|
- break; |
|
3943 |
+ if let Some(monitor_index) = monitor_index |
|
3944 |
+ && let Some(monitor) = self.monitors.get_mut(monitor_index) |
|
3945 |
+ { |
|
3946 |
+ if monitor.clients_head == Some(window) { |
|
3947 |
+ if let Some(client) = self.clients.get(&window) { |
|
3948 |
+ monitor.clients_head = client.next; |
|
3949 |
+ } |
|
3950 |
+ } else { |
|
3951 |
+ let mut current = monitor.clients_head; |
|
3952 |
+ while let Some(current_window) = current { |
|
3953 |
+ if let Some(current_client) = self.clients.get(¤t_window) { |
|
3954 |
+ if current_client.next == Some(window) { |
|
3955 |
+ let new_next = self.clients.get(&window).and_then(|c| c.next); |
|
3956 |
+ if let Some(current_client_mut) = self.clients.get_mut(¤t_window) |
|
3957 |
+ { |
|
3958 |
+ current_client_mut.next = new_next; |
| 4118 |
3959 |
} |
| 4119 |
|
- current = current_client.next; |
| 4120 |
|
- } else { |
| 4121 |
3960 |
break; |
| 4122 |
3961 |
} |
|
3962 |
+ current = current_client.next; |
|
3963 |
+ } else { |
|
3964 |
+ break; |
| 4123 |
3965 |
} |
| 4124 |
3966 |
} |
| 4125 |
3967 |
} |
|
|
@@ -4127,61 +3969,60 @@ impl WindowManager { |
| 4127 |
3969 |
} |
| 4128 |
3970 |
|
| 4129 |
3971 |
fn attach_stack(&mut self, window: Window, monitor_index: usize) { |
| 4130 |
|
- if let Some(monitor) = self.monitors.get_mut(monitor_index) { |
| 4131 |
|
- if let Some(client) = self.clients.get_mut(&window) { |
| 4132 |
|
- client.stack_next = monitor.stack_head; |
| 4133 |
|
- monitor.stack_head = Some(window); |
| 4134 |
|
- } |
|
3972 |
+ if let Some(monitor) = self.monitors.get_mut(monitor_index) |
|
3973 |
+ && let Some(client) = self.clients.get_mut(&window) |
|
3974 |
+ { |
|
3975 |
+ client.stack_next = monitor.stack_head; |
|
3976 |
+ monitor.stack_head = Some(window); |
| 4135 |
3977 |
} |
| 4136 |
3978 |
} |
| 4137 |
3979 |
|
| 4138 |
3980 |
fn detach_stack(&mut self, window: Window) { |
| 4139 |
3981 |
let monitor_index = self.clients.get(&window).map(|c| c.monitor_index); |
| 4140 |
|
- if let Some(monitor_index) = monitor_index { |
| 4141 |
|
- if let Some(monitor) = self.monitors.get_mut(monitor_index) { |
| 4142 |
|
- if monitor.stack_head == Some(window) { |
| 4143 |
|
- if let Some(client) = self.clients.get(&window) { |
| 4144 |
|
- monitor.stack_head = client.stack_next; |
| 4145 |
|
- } |
| 4146 |
|
- let should_update_selected = monitor.selected_client == Some(window); |
| 4147 |
|
- let mut new_selected: Option<Window> = None; |
| 4148 |
|
- if should_update_selected { |
| 4149 |
|
- let mut stack_current = monitor.stack_head; |
| 4150 |
|
- while let Some(stack_window) = stack_current { |
| 4151 |
|
- if let Some(stack_client) = self.clients.get(&stack_window) { |
| 4152 |
|
- if self.is_window_visible(stack_window) { |
| 4153 |
|
- new_selected = Some(stack_window); |
| 4154 |
|
- break; |
| 4155 |
|
- } |
| 4156 |
|
- stack_current = stack_client.stack_next; |
| 4157 |
|
- } else { |
|
3982 |
+ if let Some(monitor_index) = monitor_index |
|
3983 |
+ && let Some(monitor) = self.monitors.get_mut(monitor_index) |
|
3984 |
+ { |
|
3985 |
+ if monitor.stack_head == Some(window) { |
|
3986 |
+ if let Some(client) = self.clients.get(&window) { |
|
3987 |
+ monitor.stack_head = client.stack_next; |
|
3988 |
+ } |
|
3989 |
+ let should_update_selected = monitor.selected_client == Some(window); |
|
3990 |
+ let mut new_selected: Option<Window> = None; |
|
3991 |
+ if should_update_selected { |
|
3992 |
+ let mut stack_current = monitor.stack_head; |
|
3993 |
+ while let Some(stack_window) = stack_current { |
|
3994 |
+ if let Some(stack_client) = self.clients.get(&stack_window) { |
|
3995 |
+ if self.is_window_visible(stack_window) { |
|
3996 |
+ new_selected = Some(stack_window); |
| 4158 |
3997 |
break; |
| 4159 |
3998 |
} |
|
3999 |
+ stack_current = stack_client.stack_next; |
|
4000 |
+ } else { |
|
4001 |
+ break; |
| 4160 |
4002 |
} |
| 4161 |
4003 |
} |
| 4162 |
|
- if should_update_selected { |
| 4163 |
|
- if let Some(monitor) = self.monitors.get_mut(monitor_index) { |
| 4164 |
|
- monitor.selected_client = new_selected; |
| 4165 |
|
- } |
| 4166 |
|
- } |
| 4167 |
|
- } else { |
| 4168 |
|
- let mut current = monitor.stack_head; |
| 4169 |
|
- while let Some(current_window) = current { |
| 4170 |
|
- if let Some(current_client) = self.clients.get(¤t_window) { |
| 4171 |
|
- if current_client.stack_next == Some(window) { |
| 4172 |
|
- let new_stack_next = |
| 4173 |
|
- self.clients.get(&window).and_then(|c| c.stack_next); |
| 4174 |
|
- if let Some(current_client_mut) = |
| 4175 |
|
- self.clients.get_mut(¤t_window) |
| 4176 |
|
- { |
| 4177 |
|
- current_client_mut.stack_next = new_stack_next; |
| 4178 |
|
- } |
| 4179 |
|
- break; |
|
4004 |
+ } |
|
4005 |
+ if should_update_selected |
|
4006 |
+ && let Some(monitor) = self.monitors.get_mut(monitor_index) |
|
4007 |
+ { |
|
4008 |
+ monitor.selected_client = new_selected; |
|
4009 |
+ } |
|
4010 |
+ } else { |
|
4011 |
+ let mut current = monitor.stack_head; |
|
4012 |
+ while let Some(current_window) = current { |
|
4013 |
+ if let Some(current_client) = self.clients.get(¤t_window) { |
|
4014 |
+ if current_client.stack_next == Some(window) { |
|
4015 |
+ let new_stack_next = |
|
4016 |
+ self.clients.get(&window).and_then(|c| c.stack_next); |
|
4017 |
+ if let Some(current_client_mut) = self.clients.get_mut(¤t_window) |
|
4018 |
+ { |
|
4019 |
+ current_client_mut.stack_next = new_stack_next; |
| 4180 |
4020 |
} |
| 4181 |
|
- current = current_client.stack_next; |
| 4182 |
|
- } else { |
| 4183 |
4021 |
break; |
| 4184 |
4022 |
} |
|
4023 |
+ current = current_client.stack_next; |
|
4024 |
+ } else { |
|
4025 |
+ break; |
| 4185 |
4026 |
} |
| 4186 |
4027 |
} |
| 4187 |
4028 |
} |