| @@ -127,11 +127,9 @@ pub struct WindowManager { |
| 127 |
gaps_enabled: bool, |
127 |
gaps_enabled: bool, |
| 128 |
floating_windows: HashSet<Window>, |
128 |
floating_windows: HashSet<Window>, |
| 129 |
fullscreen_windows: HashSet<Window>, |
129 |
fullscreen_windows: HashSet<Window>, |
| 130 |
- floating_geometry_before_fullscreen: HashMap<Window, (i16, i16, u16, u16, u16)>, |
|
|
| 131 |
bars: Vec<Bar>, |
130 |
bars: Vec<Bar>, |
| 132 |
tab_bars: Vec<crate::tab_bar::TabBar>, |
131 |
tab_bars: Vec<crate::tab_bar::TabBar>, |
| 133 |
show_bar: bool, |
132 |
show_bar: bool, |
| 134 |
- last_layout: Option<&'static str>, |
|
|
| 135 |
monitors: Vec<Monitor>, |
133 |
monitors: Vec<Monitor>, |
| 136 |
selected_monitor: usize, |
134 |
selected_monitor: usize, |
| 137 |
atoms: AtomCache, |
135 |
atoms: AtomCache, |
| @@ -286,11 +284,9 @@ impl WindowManager { |
| 286 |
gaps_enabled, |
284 |
gaps_enabled, |
| 287 |
floating_windows: HashSet::new(), |
285 |
floating_windows: HashSet::new(), |
| 288 |
fullscreen_windows: HashSet::new(), |
286 |
fullscreen_windows: HashSet::new(), |
| 289 |
- floating_geometry_before_fullscreen: HashMap::new(), |
|
|
| 290 |
bars, |
287 |
bars, |
| 291 |
tab_bars, |
288 |
tab_bars, |
| 292 |
show_bar: true, |
289 |
show_bar: true, |
| 293 |
- last_layout: None, |
|
|
| 294 |
monitors, |
290 |
monitors, |
| 295 |
selected_monitor: 0, |
291 |
selected_monitor: 0, |
| 296 |
atoms, |
292 |
atoms, |
| @@ -316,16 +312,7 @@ impl WindowManager { |
| 316 |
Ok(window_manager) |
312 |
Ok(window_manager) |
| 317 |
} |
313 |
} |
| 318 |
|
314 |
|
| 319 |
- pub fn show_migration_overlay(&mut self) { |
315 |
+ pub fn show_startup_config_error(&mut self, error: &str) { |
| 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 |
- |
|
|
| 329 |
let monitor = &self.monitors[self.selected_monitor]; |
316 |
let monitor = &self.monitors[self.selected_monitor]; |
| 330 |
let monitor_x = monitor.screen_x as i16; |
317 |
let monitor_x = monitor.screen_x as i16; |
| 331 |
let monitor_y = monitor.screen_y as i16; |
318 |
let monitor_y = monitor.screen_y as i16; |
| @@ -335,13 +322,13 @@ impl WindowManager { |
| 335 |
if let Err(e) = self.overlay.show_error( |
322 |
if let Err(e) = self.overlay.show_error( |
| 336 |
&self.connection, |
323 |
&self.connection, |
| 337 |
&self.font, |
324 |
&self.font, |
| 338 |
- message, |
325 |
+ error, |
| 339 |
monitor_x, |
326 |
monitor_x, |
| 340 |
monitor_y, |
327 |
monitor_y, |
| 341 |
screen_width, |
328 |
screen_width, |
| 342 |
screen_height, |
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 |
|
| @@ -751,13 +738,6 @@ impl WindowManager { |
| 751 |
} |
738 |
} |
| 752 |
} |
739 |
} |
| 753 |
KeyAction::ToggleFullScreen => { |
740 |
KeyAction::ToggleFullScreen => { |
| 754 |
- // Disable gaps and save previous state in config if not already in fullscreen |
|
|
| 755 |
- if self.fullscreen_windows.is_empty() { |
|
|
| 756 |
- self.config.gaps_enabled = std::mem::take(&mut self.gaps_enabled); |
|
|
| 757 |
- } else { |
|
|
| 758 |
- self.gaps_enabled = self.config.gaps_enabled; |
|
|
| 759 |
- } |
|
|
| 760 |
- |
|
|
| 761 |
self.fullscreen()?; |
741 |
self.fullscreen()?; |
| 762 |
self.restack()?; |
742 |
self.restack()?; |
| 763 |
} |
743 |
} |
| @@ -1466,155 +1446,16 @@ impl WindowManager { |
| 1466 |
} |
1446 |
} |
| 1467 |
|
1447 |
|
| 1468 |
fn fullscreen(&mut self) -> WmResult<()> { |
1448 |
fn fullscreen(&mut self) -> WmResult<()> { |
| 1469 |
- if self.show_bar { |
1449 |
+ let Some(focused_window) = self |
| 1470 |
- let Some(focused_window) = self |
1450 |
+ .monitors |
| 1471 |
- .monitors |
1451 |
+ .get(self.selected_monitor) |
| 1472 |
- .get(self.selected_monitor) |
1452 |
+ .and_then(|m| m.selected_client) |
| 1473 |
- .and_then(|m| m.selected_client) |
1453 |
+ else { |
| 1474 |
- else { |
1454 |
+ return Ok(()); |
| 1475 |
- return Ok(()); |
1455 |
+ }; |
| 1476 |
- }; |
|
|
| 1477 |
- |
|
|
| 1478 |
- self.fullscreen_windows.insert(focused_window); |
|
|
| 1479 |
- |
|
|
| 1480 |
- let windows: Vec<Window> = self |
|
|
| 1481 |
- .windows |
|
|
| 1482 |
- .iter() |
|
|
| 1483 |
- .filter(|&&w| self.is_window_visible(w)) |
|
|
| 1484 |
- .copied() |
|
|
| 1485 |
- .collect(); |
|
|
| 1486 |
- |
|
|
| 1487 |
- for window in &windows { |
|
|
| 1488 |
- if let Ok(geom) = self.connection.get_geometry(*window)?.reply() { |
|
|
| 1489 |
- self.floating_geometry_before_fullscreen.insert( |
|
|
| 1490 |
- *window, |
|
|
| 1491 |
- (geom.x, geom.y, geom.width, geom.height, geom.border_width), |
|
|
| 1492 |
- ); |
|
|
| 1493 |
- } |
|
|
| 1494 |
- } |
|
|
| 1495 |
- |
|
|
| 1496 |
- self.last_layout = Some(self.layout.name()); |
|
|
| 1497 |
- if let Ok(layout) = layout_from_str("monocle") { |
|
|
| 1498 |
- self.layout = layout; |
|
|
| 1499 |
- } |
|
|
| 1500 |
- self.toggle_bar()?; |
|
|
| 1501 |
- self.apply_layout()?; |
|
|
| 1502 |
- |
|
|
| 1503 |
- for window in &windows { |
|
|
| 1504 |
- self.connection.configure_window( |
|
|
| 1505 |
- *window, |
|
|
| 1506 |
- &x11rb::protocol::xproto::ConfigureWindowAux::new().border_width(0), |
|
|
| 1507 |
- )?; |
|
|
| 1508 |
- } |
|
|
| 1509 |
- |
|
|
| 1510 |
- let border_width = self.config.border_width; |
|
|
| 1511 |
- let floating_windows: Vec<Window> = windows |
|
|
| 1512 |
- .iter() |
|
|
| 1513 |
- .filter(|&&w| self.floating_windows.contains(&w)) |
|
|
| 1514 |
- .copied() |
|
|
| 1515 |
- .collect(); |
|
|
| 1516 |
- |
|
|
| 1517 |
- for window in floating_windows { |
|
|
| 1518 |
- let monitor_idx = self |
|
|
| 1519 |
- .clients |
|
|
| 1520 |
- .get(&window) |
|
|
| 1521 |
- .map(|c| c.monitor_index) |
|
|
| 1522 |
- .unwrap_or(self.selected_monitor); |
|
|
| 1523 |
- let monitor = &self.monitors[monitor_idx]; |
|
|
| 1524 |
- |
|
|
| 1525 |
- let (outer_gap_h, outer_gap_v) = if self.gaps_enabled { |
|
|
| 1526 |
- ( |
|
|
| 1527 |
- self.config.gap_outer_horizontal, |
|
|
| 1528 |
- self.config.gap_outer_vertical, |
|
|
| 1529 |
- ) |
|
|
| 1530 |
- } else { |
|
|
| 1531 |
- (0, 0) |
|
|
| 1532 |
- }; |
|
|
| 1533 |
- |
|
|
| 1534 |
- let window_x = monitor.screen_x + outer_gap_h as i32; |
|
|
| 1535 |
- let window_y = monitor.screen_y + outer_gap_v as i32; |
|
|
| 1536 |
- let window_width = monitor |
|
|
| 1537 |
- .screen_width |
|
|
| 1538 |
- .saturating_sub(2 * outer_gap_h as i32) |
|
|
| 1539 |
- .saturating_sub(2 * border_width as i32); |
|
|
| 1540 |
- let window_height = monitor |
|
|
| 1541 |
- .screen_height |
|
|
| 1542 |
- .saturating_sub(2 * outer_gap_v as i32) |
|
|
| 1543 |
- .saturating_sub(2 * border_width as i32); |
|
|
| 1544 |
- |
|
|
| 1545 |
- self.connection.configure_window( |
|
|
| 1546 |
- window, |
|
|
| 1547 |
- &x11rb::protocol::xproto::ConfigureWindowAux::new() |
|
|
| 1548 |
- .x(window_x) |
|
|
| 1549 |
- .y(window_y) |
|
|
| 1550 |
- .width(window_width as u32) |
|
|
| 1551 |
- .height(window_height as u32), |
|
|
| 1552 |
- )?; |
|
|
| 1553 |
- } |
|
|
| 1554 |
- self.connection.flush()?; |
|
|
| 1555 |
- } else { |
|
|
| 1556 |
- let Some(focused_window) = self |
|
|
| 1557 |
- .monitors |
|
|
| 1558 |
- .get(self.selected_monitor) |
|
|
| 1559 |
- .and_then(|m| m.selected_client) |
|
|
| 1560 |
- else { |
|
|
| 1561 |
- return Ok(()); |
|
|
| 1562 |
- }; |
|
|
| 1563 |
- |
|
|
| 1564 |
- self.fullscreen_windows.remove(&focused_window); |
|
|
| 1565 |
- |
|
|
| 1566 |
- if let Some(last) = self.last_layout |
|
|
| 1567 |
- && let Ok(layout) = layout_from_str(last) |
|
|
| 1568 |
- { |
|
|
| 1569 |
- self.layout = layout; |
|
|
| 1570 |
- } |
|
|
| 1571 |
- |
|
|
| 1572 |
- let windows_to_restore: Vec<Window> = self |
|
|
| 1573 |
- .floating_geometry_before_fullscreen |
|
|
| 1574 |
- .keys() |
|
|
| 1575 |
- .copied() |
|
|
| 1576 |
- .collect(); |
|
|
| 1577 |
- |
|
|
| 1578 |
- for window in windows_to_restore { |
|
|
| 1579 |
- if let Some(&(x, y, width, height, border_width)) = |
|
|
| 1580 |
- self.floating_geometry_before_fullscreen.get(&window) |
|
|
| 1581 |
- { |
|
|
| 1582 |
- self.connection.configure_window( |
|
|
| 1583 |
- window, |
|
|
| 1584 |
- &ConfigureWindowAux::new() |
|
|
| 1585 |
- .x(x as i32) |
|
|
| 1586 |
- .y(y as i32) |
|
|
| 1587 |
- .width(width as u32) |
|
|
| 1588 |
- .height(height as u32) |
|
|
| 1589 |
- .border_width(border_width as u32), |
|
|
| 1590 |
- )?; |
|
|
| 1591 |
- |
|
|
| 1592 |
- if let Some(c) = self.clients.get_mut(&window) { |
|
|
| 1593 |
- c.x_position = x; |
|
|
| 1594 |
- c.y_position = y; |
|
|
| 1595 |
- c.width = width; |
|
|
| 1596 |
- c.height = height; |
|
|
| 1597 |
- c.border_width = border_width; |
|
|
| 1598 |
- } |
|
|
| 1599 |
- |
|
|
| 1600 |
- self.floating_geometry_before_fullscreen.remove(&window); |
|
|
| 1601 |
- } |
|
|
| 1602 |
- } |
|
|
| 1603 |
- self.connection.flush()?; |
|
|
| 1604 |
- |
|
|
| 1605 |
- self.toggle_bar()?; |
|
|
| 1606 |
|
1456 |
|
| 1607 |
- if self.layout.name() != "normie" { |
1457 |
+ let is_fullscreen = self.fullscreen_windows.contains(&focused_window); |
| 1608 |
- self.apply_layout()?; |
1458 |
+ self.set_window_fullscreen(focused_window, !is_fullscreen)?; |
| 1609 |
- } else 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 |
Ok(()) |
1459 |
Ok(()) |
| 1619 |
} |
1460 |
} |
| 1620 |
|
1461 |
|
| @@ -1642,11 +1483,15 @@ impl WindowManager { |
| 1642 |
client.is_fullscreen = true; |
1483 |
client.is_fullscreen = true; |
| 1643 |
client.old_state = client.is_floating; |
1484 |
client.old_state = client.is_floating; |
| 1644 |
client.old_border_width = client.border_width; |
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; |
| 1645 |
client.border_width = 0; |
1490 |
client.border_width = 0; |
| 1646 |
- client.is_floating = true; |
|
|
| 1647 |
} |
1491 |
} |
| 1648 |
|
1492 |
|
| 1649 |
self.fullscreen_windows.insert(window); |
1493 |
self.fullscreen_windows.insert(window); |
|
|
1494 |
+ self.floating_windows.insert(window); |
| 1650 |
|
1495 |
|
| 1651 |
self.connection.configure_window( |
1496 |
self.connection.configure_window( |
| 1652 |
window, |
1497 |
window, |
| @@ -1673,26 +1518,20 @@ impl WindowManager { |
| 1673 |
|
1518 |
|
| 1674 |
self.fullscreen_windows.remove(&window); |
1519 |
self.fullscreen_windows.remove(&window); |
| 1675 |
|
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 |
+ |
| 1676 |
if let Some(client) = self.clients.get_mut(&window) { |
1531 |
if let Some(client) = self.clients.get_mut(&window) { |
| 1677 |
client.is_fullscreen = false; |
1532 |
client.is_fullscreen = false; |
| 1678 |
client.is_floating = client.old_state; |
1533 |
client.is_floating = client.old_state; |
| 1679 |
client.border_width = client.old_border_width; |
1534 |
client.border_width = client.old_border_width; |
| 1680 |
- |
|
|
| 1681 |
- let x = client.old_x_position; |
|
|
| 1682 |
- let y = client.old_y_position; |
|
|
| 1683 |
- let w = client.old_width; |
|
|
| 1684 |
- let h = client.old_height; |
|
|
| 1685 |
- let bw = client.border_width; |
|
|
| 1686 |
- |
|
|
| 1687 |
- self.connection.configure_window( |
|
|
| 1688 |
- window, |
|
|
| 1689 |
- &x11rb::protocol::xproto::ConfigureWindowAux::new() |
|
|
| 1690 |
- .x(x as i32) |
|
|
| 1691 |
- .y(y as i32) |
|
|
| 1692 |
- .width(w as u32) |
|
|
| 1693 |
- .height(h as u32) |
|
|
| 1694 |
- .border_width(bw as u32), |
|
|
| 1695 |
- )?; |
|
|
| 1696 |
} |
1535 |
} |
| 1697 |
|
1536 |
|
| 1698 |
self.apply_layout()?; |
1537 |
self.apply_layout()?; |
| @@ -1701,20 +1540,6 @@ impl WindowManager { |
| 1701 |
Ok(()) |
1540 |
Ok(()) |
| 1702 |
} |
1541 |
} |
| 1703 |
|
1542 |
|
| 1704 |
- fn toggle_bar(&mut self) -> WmResult<()> { |
|
|
| 1705 |
- self.show_bar = !self.show_bar; |
|
|
| 1706 |
- if let Some(bar) = self.bars.get(self.selected_monitor) { |
|
|
| 1707 |
- if self.show_bar { |
|
|
| 1708 |
- self.connection.map_window(bar.window())?; |
|
|
| 1709 |
- } else { |
|
|
| 1710 |
- self.connection.unmap_window(bar.window())?; |
|
|
| 1711 |
- } |
|
|
| 1712 |
- self.connection.flush()?; |
|
|
| 1713 |
- } |
|
|
| 1714 |
- self.apply_layout()?; |
|
|
| 1715 |
- Ok(()) |
|
|
| 1716 |
- } |
|
|
| 1717 |
- |
|
|
| 1718 |
fn get_transient_parent(&self, window: Window) -> Option<Window> { |
1543 |
fn get_transient_parent(&self, window: Window) -> Option<Window> { |
| 1719 |
self.connection |
1544 |
self.connection |
| 1720 |
.get_property( |
1545 |
.get_property( |
| @@ -3525,6 +3350,44 @@ impl WindowManager { |
| 3525 |
self.showhide(stack_head)?; |
3350 |
self.showhide(stack_head)?; |
| 3526 |
} |
3351 |
} |
| 3527 |
|
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 |
+ |
| 3528 |
self.connection.flush()?; |
3391 |
self.connection.flush()?; |
| 3529 |
|
3392 |
|
| 3530 |
let is_tabbed = self.layout.name() == LayoutType::Tabbed.as_str(); |
3393 |
let is_tabbed = self.layout.name() == LayoutType::Tabbed.as_str(); |