Add layer shell exclusive zone support
Browse files at this commit953d1064c280cacf5c4c6bf7bcf79eece4e4235aParent: 4a585a34 changed files +110 -47
- src/handlers/layer_shell.rs +2 -2
- src/handlers/xdg_shell.rs +4 -3
- src/layout.rs +102 -41
- src/niri.rs +2 -1
src/handlers/layer_shell.rsmodified+2 -2
| @@ -49,7 +49,7 @@ impl WlrLayerShellHandler for State { | |||
| 49 | None | 49 | None |
| 50 | }; | 50 | }; |
| 51 | if let Some(output) = output { | 51 | if let Some(output) = output { |
| 52 | - self.niri.queue_redraw(output); | 52 | + self.niri.output_resized(output); |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | } | 55 | } |
| @@ -96,6 +96,6 @@ impl State { | |||
| 96 | } | 96 | } |
| 97 | drop(map); | 97 | drop(map); |
| 98 | 98 | ||
| 99 | - self.niri.queue_redraw(output); | 99 | + self.niri.output_resized(output); |
| 100 | } | 100 | } |
| 101 | } | 101 | } |
src/handlers/xdg_shell.rsmodified+4 -3
| @@ -1,4 +1,4 @@ | |||
| 1 | -use smithay::desktop::{find_popup_root_surface, PopupKind, Window}; | 1 | +use smithay::desktop::{find_popup_root_surface, layer_map_for_output, PopupKind, Window}; |
| 2 | use smithay::output::Output; | 2 | use smithay::output::Output; |
| 3 | use smithay::reexports::wayland_protocols::xdg::decoration::zv1::server::zxdg_toplevel_decoration_v1; | 3 | use smithay::reexports::wayland_protocols::xdg::decoration::zv1::server::zxdg_toplevel_decoration_v1; |
| 4 | use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::{self, ResizeEdge}; | 4 | use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::{self, ResizeEdge}; |
| @@ -14,7 +14,7 @@ use smithay::wayland::shell::xdg::{ | |||
| 14 | }; | 14 | }; |
| 15 | use smithay::{delegate_xdg_decoration, delegate_xdg_shell}; | 15 | use smithay::{delegate_xdg_decoration, delegate_xdg_shell}; |
| 16 | 16 | ||
| 17 | -use crate::layout::{configure_new_window, output_size}; | 17 | +use crate::layout::configure_new_window; |
| 18 | use crate::niri::State; | 18 | use crate::niri::State; |
| 19 | 19 | ||
| 20 | impl XdgShellHandler for State { | 20 | impl XdgShellHandler for State { |
| @@ -28,7 +28,8 @@ impl XdgShellHandler for State { | |||
| 28 | 28 | ||
| 29 | // Tell the surface the preferred size and bounds for its likely output. | 29 | // Tell the surface the preferred size and bounds for its likely output. |
| 30 | let output = self.niri.monitor_set.active_output().unwrap(); | 30 | let output = self.niri.monitor_set.active_output().unwrap(); |
| 31 | - configure_new_window(output_size(output), &window); | 31 | + let working_area = layer_map_for_output(output).non_exclusive_zone(); |
| 32 | + configure_new_window(working_area, &window); | ||
| 32 | 33 | ||
| 33 | // At the moment of creation, xdg toplevels must have no buffer. | 34 | // At the moment of creation, xdg toplevels must have no buffer. |
| 34 | let existing = self.niri.unmapped_windows.insert(wl_surface, window); | 35 | let existing = self.niri.unmapped_windows.insert(wl_surface, window); |
src/layout.rsmodified+102 -41
| @@ -42,7 +42,7 @@ use smithay::backend::renderer::element::{AsRenderElements, Kind}; | |||
| 42 | use smithay::backend::renderer::gles::GlesRenderer; | 42 | use smithay::backend::renderer::gles::GlesRenderer; |
| 43 | use smithay::backend::renderer::ImportAll; | 43 | use smithay::backend::renderer::ImportAll; |
| 44 | use smithay::desktop::space::SpaceElement; | 44 | use smithay::desktop::space::SpaceElement; |
| 45 | -use smithay::desktop::Window; | 45 | +use smithay::desktop::{layer_map_for_output, Window}; |
| 46 | use smithay::output::Output; | 46 | use smithay::output::Output; |
| 47 | use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; | 47 | use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; |
| 48 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; | 48 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; |
| @@ -143,6 +143,12 @@ pub struct Workspace<W: LayoutElement> { | |||
| 143 | /// been disconnected, preserved until a new output is connected. | 143 | /// been disconnected, preserved until a new output is connected. |
| 144 | view_size: Size<i32, Logical>, | 144 | view_size: Size<i32, Logical>, |
| 145 | 145 | ||
| 146 | + /// Latest known working area for this workspace. | ||
| 147 | + /// | ||
| 148 | + /// This is similar to view size, but takes into account things like layer shell exclusive | ||
| 149 | + /// zones. | ||
| 150 | + working_area: Rectangle<i32, Logical>, | ||
| 151 | + | ||
| 146 | /// Columns of windows on this workspace. | 152 | /// Columns of windows on this workspace. |
| 147 | columns: Vec<Column<W>>, | 153 | columns: Vec<Column<W>>, |
| 148 | 154 | ||
| @@ -598,16 +604,20 @@ impl<W: LayoutElement> MonitorSet<W> { | |||
| 598 | None | 604 | None |
| 599 | } | 605 | } |
| 600 | 606 | ||
| 601 | - pub fn update_output(&mut self, output: &Output) { | 607 | + pub fn update_output_size(&mut self, output: &Output) { |
| 602 | let MonitorSet::Normal { monitors, .. } = self else { | 608 | let MonitorSet::Normal { monitors, .. } = self else { |
| 603 | panic!() | 609 | panic!() |
| 604 | }; | 610 | }; |
| 605 | 611 | ||
| 606 | for mon in monitors { | 612 | for mon in monitors { |
| 607 | if &mon.output == output { | 613 | if &mon.output == output { |
| 614 | + let view_size = output_size(output); | ||
| 615 | + let working_area = layer_map_for_output(output).non_exclusive_zone(); | ||
| 616 | + | ||
| 608 | for ws in &mut mon.workspaces { | 617 | for ws in &mut mon.workspaces { |
| 609 | - ws.set_view_size(output_size(output)); | 618 | + ws.set_view_size(view_size, working_area); |
| 610 | } | 619 | } |
| 620 | + | ||
| 611 | break; | 621 | break; |
| 612 | } | 622 | } |
| 613 | } | 623 | } |
| @@ -1390,6 +1400,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1390 | Self { | 1400 | Self { |
| 1391 | original_output: OutputId::new(&output), | 1401 | original_output: OutputId::new(&output), |
| 1392 | view_size: output_size(&output), | 1402 | view_size: output_size(&output), |
| 1403 | + working_area: Rectangle::from_loc_and_size((0, 0), output_size(&output)), | ||
| 1393 | output: Some(output), | 1404 | output: Some(output), |
| 1394 | columns: vec![], | 1405 | columns: vec![], |
| 1395 | active_column_idx: 0, | 1406 | active_column_idx: 0, |
| @@ -1405,6 +1416,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1405 | output: None, | 1416 | output: None, |
| 1406 | original_output: OutputId(String::new()), | 1417 | original_output: OutputId(String::new()), |
| 1407 | view_size: Size::from((1280, 720)), | 1418 | view_size: Size::from((1280, 720)), |
| 1419 | + working_area: Rectangle::from_loc_and_size((0, 0), (1280, 720)), | ||
| 1408 | columns: vec![], | 1420 | columns: vec![], |
| 1409 | active_column_idx: 0, | 1421 | active_column_idx: 0, |
| 1410 | focus_ring: FocusRing::default(), | 1422 | focus_ring: FocusRing::default(), |
| @@ -1463,7 +1475,8 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1463 | self.output = output; | 1475 | self.output = output; |
| 1464 | 1476 | ||
| 1465 | if let Some(output) = &self.output { | 1477 | if let Some(output) = &self.output { |
| 1466 | - self.set_view_size(output_size(output)); | 1478 | + let working_area = layer_map_for_output(output).non_exclusive_zone(); |
| 1479 | + self.set_view_size(output_size(output), working_area); | ||
| 1467 | 1480 | ||
| 1468 | for win in self.windows() { | 1481 | for win in self.windows() { |
| 1469 | self.enter_output_for_window(win); | 1482 | self.enter_output_for_window(win); |
| @@ -1481,14 +1494,16 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1481 | } | 1494 | } |
| 1482 | } | 1495 | } |
| 1483 | 1496 | ||
| 1484 | - fn set_view_size(&mut self, size: Size<i32, Logical>) { | 1497 | + fn set_view_size(&mut self, size: Size<i32, Logical>, working_area: Rectangle<i32, Logical>) { |
| 1485 | - if self.view_size == size { | 1498 | + if self.view_size == size && self.working_area == working_area { |
| 1486 | return; | 1499 | return; |
| 1487 | } | 1500 | } |
| 1488 | 1501 | ||
| 1489 | self.view_size = size; | 1502 | self.view_size = size; |
| 1503 | + self.working_area = working_area; | ||
| 1504 | + | ||
| 1490 | for col in &mut self.columns { | 1505 | for col in &mut self.columns { |
| 1491 | - col.update_window_sizes(self.view_size); | 1506 | + col.update_window_sizes(self.view_size, self.working_area); |
| 1492 | } | 1507 | } |
| 1493 | } | 1508 | } |
| 1494 | 1509 | ||
| @@ -1507,7 +1522,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1507 | let new_x = self.column_x(idx) - PADDING; | 1522 | let new_x = self.column_x(idx) - PADDING; |
| 1508 | let new_view_offset = compute_new_view_offset( | 1523 | let new_view_offset = compute_new_view_offset( |
| 1509 | current_x, | 1524 | current_x, |
| 1510 | - self.view_size.w, | 1525 | + self.working_area.size.w, |
| 1511 | new_x, | 1526 | new_x, |
| 1512 | self.columns[idx].size().w, | 1527 | self.columns[idx].size().w, |
| 1513 | ); | 1528 | ); |
| @@ -1553,7 +1568,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1553 | self.active_column_idx + 1 | 1568 | self.active_column_idx + 1 |
| 1554 | }; | 1569 | }; |
| 1555 | 1570 | ||
| 1556 | - let column = Column::new(window, self.view_size); | 1571 | + let column = Column::new(window, self.view_size, self.working_area); |
| 1557 | self.columns.insert(idx, column); | 1572 | self.columns.insert(idx, column); |
| 1558 | 1573 | ||
| 1559 | if activate { | 1574 | if activate { |
| @@ -1606,7 +1621,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1606 | } | 1621 | } |
| 1607 | 1622 | ||
| 1608 | column.active_window_idx = min(column.active_window_idx, column.windows.len() - 1); | 1623 | column.active_window_idx = min(column.active_window_idx, column.windows.len() - 1); |
| 1609 | - column.update_window_sizes(self.view_size); | 1624 | + column.update_window_sizes(self.view_size, self.working_area); |
| 1610 | } | 1625 | } |
| 1611 | 1626 | ||
| 1612 | fn update_window(&mut self, window: &W) { | 1627 | fn update_window(&mut self, window: &W) { |
| @@ -1616,7 +1631,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1616 | .enumerate() | 1631 | .enumerate() |
| 1617 | .find(|(_, col)| col.contains(window)) | 1632 | .find(|(_, col)| col.contains(window)) |
| 1618 | .unwrap(); | 1633 | .unwrap(); |
| 1619 | - column.update_window_sizes(self.view_size); | 1634 | + column.update_window_sizes(self.view_size, self.working_area); |
| 1620 | 1635 | ||
| 1621 | if idx == self.active_column_idx { | 1636 | if idx == self.active_column_idx { |
| 1622 | // We might need to move the view to ensure the resized window is still visible. | 1637 | // We might need to move the view to ensure the resized window is still visible. |
| @@ -1625,7 +1640,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1625 | 1640 | ||
| 1626 | let new_view_offset = compute_new_view_offset( | 1641 | let new_view_offset = compute_new_view_offset( |
| 1627 | current_x, | 1642 | current_x, |
| 1628 | - self.view_size.w, | 1643 | + self.working_area.size.w, |
| 1629 | new_x, | 1644 | new_x, |
| 1630 | self.columns[idx].size().w, | 1645 | self.columns[idx].size().w, |
| 1631 | ); | 1646 | ); |
| @@ -1714,7 +1729,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1714 | let new_x = self.column_x(self.active_column_idx) - PADDING; | 1729 | let new_x = self.column_x(self.active_column_idx) - PADDING; |
| 1715 | let new_view_offset = compute_new_view_offset( | 1730 | let new_view_offset = compute_new_view_offset( |
| 1716 | current_x, | 1731 | current_x, |
| 1717 | - self.view_size.w, | 1732 | + self.working_area.size.w, |
| 1718 | new_x, | 1733 | new_x, |
| 1719 | self.columns[self.active_column_idx].size().w, | 1734 | self.columns[self.active_column_idx].size().w, |
| 1720 | ); | 1735 | ); |
| @@ -1740,7 +1755,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1740 | let new_x = self.column_x(self.active_column_idx) - PADDING; | 1755 | let new_x = self.column_x(self.active_column_idx) - PADDING; |
| 1741 | let new_view_offset = compute_new_view_offset( | 1756 | let new_view_offset = compute_new_view_offset( |
| 1742 | current_x, | 1757 | current_x, |
| 1743 | - self.view_size.w, | 1758 | + self.working_area.size.w, |
| 1744 | new_x, | 1759 | new_x, |
| 1745 | self.columns[self.active_column_idx].size().w, | 1760 | self.columns[self.active_column_idx].size().w, |
| 1746 | ); | 1761 | ); |
| @@ -1781,7 +1796,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1781 | self.remove_window(&window); | 1796 | self.remove_window(&window); |
| 1782 | 1797 | ||
| 1783 | let target_column = &mut self.columns[self.active_column_idx]; | 1798 | let target_column = &mut self.columns[self.active_column_idx]; |
| 1784 | - target_column.add_window(self.view_size, window); | 1799 | + target_column.add_window(self.view_size, self.working_area, window); |
| 1785 | } | 1800 | } |
| 1786 | 1801 | ||
| 1787 | fn expel_from_column(&mut self) { | 1802 | fn expel_from_column(&mut self) { |
| @@ -1842,6 +1857,8 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1842 | if col.is_fullscreen { | 1857 | if col.is_fullscreen { |
| 1843 | // FIXME: fullscreen windows are missing left padding | 1858 | // FIXME: fullscreen windows are missing left padding |
| 1844 | win_pos.x -= PADDING; | 1859 | win_pos.x -= PADDING; |
| 1860 | + } else { | ||
| 1861 | + win_pos += self.working_area.loc; | ||
| 1845 | } | 1862 | } |
| 1846 | if active_win.is_in_input_region(&(pos - win_pos.to_f64())) { | 1863 | if active_win.is_in_input_region(&(pos - win_pos.to_f64())) { |
| 1847 | let mut win_pos_within_output = win_pos; | 1864 | let mut win_pos_within_output = win_pos; |
| @@ -1863,6 +1880,8 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1863 | // FIXME: fullscreen windows are missing left padding | 1880 | // FIXME: fullscreen windows are missing left padding |
| 1864 | win_pos.x -= PADDING; | 1881 | win_pos.x -= PADDING; |
| 1865 | win_pos.y -= PADDING; | 1882 | win_pos.y -= PADDING; |
| 1883 | + } else { | ||
| 1884 | + win_pos += self.working_area.loc; | ||
| 1866 | } | 1885 | } |
| 1867 | if win.is_in_input_region(&(pos - win_pos.to_f64())) { | 1886 | if win.is_in_input_region(&(pos - win_pos.to_f64())) { |
| 1868 | let mut win_pos_within_output = win_pos; | 1887 | let mut win_pos_within_output = win_pos; |
| @@ -1885,7 +1904,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1885 | return; | 1904 | return; |
| 1886 | } | 1905 | } |
| 1887 | 1906 | ||
| 1888 | - self.columns[self.active_column_idx].toggle_width(self.view_size); | 1907 | + self.columns[self.active_column_idx].toggle_width(self.view_size, self.working_area); |
| 1889 | } | 1908 | } |
| 1890 | 1909 | ||
| 1891 | fn toggle_full_width(&mut self) { | 1910 | fn toggle_full_width(&mut self) { |
| @@ -1893,7 +1912,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1893 | return; | 1912 | return; |
| 1894 | } | 1913 | } |
| 1895 | 1914 | ||
| 1896 | - self.columns[self.active_column_idx].toggle_full_width(self.view_size); | 1915 | + self.columns[self.active_column_idx].toggle_full_width(self.view_size, self.working_area); |
| 1897 | } | 1916 | } |
| 1898 | 1917 | ||
| 1899 | pub fn set_fullscreen(&mut self, window: &W, is_fullscreen: bool) { | 1918 | pub fn set_fullscreen(&mut self, window: &W, is_fullscreen: bool) { |
| @@ -1917,18 +1936,20 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1917 | self.active_column_idx == col_idx && col.active_window_idx == win_idx; | 1936 | self.active_column_idx == col_idx && col.active_window_idx == win_idx; |
| 1918 | let window = col.windows.remove(win_idx); | 1937 | let window = col.windows.remove(win_idx); |
| 1919 | col.active_window_idx = min(col.active_window_idx, col.windows.len() - 1); | 1938 | col.active_window_idx = min(col.active_window_idx, col.windows.len() - 1); |
| 1920 | - col.update_window_sizes(self.view_size); | 1939 | + col.update_window_sizes(self.view_size, self.working_area); |
| 1921 | 1940 | ||
| 1922 | col_idx += 1; | 1941 | col_idx += 1; |
| 1923 | - self.columns | 1942 | + self.columns.insert( |
| 1924 | - .insert(col_idx, Column::new(window, self.view_size)); | 1943 | + col_idx, |
| 1944 | + Column::new(window, self.view_size, self.working_area), | ||
| 1945 | + ); | ||
| 1925 | if self.active_column_idx >= col_idx || target_window_was_focused { | 1946 | if self.active_column_idx >= col_idx || target_window_was_focused { |
| 1926 | self.active_column_idx += 1; | 1947 | self.active_column_idx += 1; |
| 1927 | } | 1948 | } |
| 1928 | col = &mut self.columns[col_idx]; | 1949 | col = &mut self.columns[col_idx]; |
| 1929 | } | 1950 | } |
| 1930 | 1951 | ||
| 1931 | - col.set_fullscreen(self.view_size, is_fullscreen); | 1952 | + col.set_fullscreen(self.view_size, self.working_area, is_fullscreen); |
| 1932 | } | 1953 | } |
| 1933 | 1954 | ||
| 1934 | pub fn toggle_fullscreen(&mut self, window: &W) { | 1955 | pub fn toggle_fullscreen(&mut self, window: &W) { |
| @@ -1983,6 +2004,8 @@ impl Workspace<Window> { | |||
| 1983 | if col.is_fullscreen { | 2004 | if col.is_fullscreen { |
| 1984 | // FIXME: fullscreen windows are missing left padding | 2005 | // FIXME: fullscreen windows are missing left padding |
| 1985 | win_pos.x -= PADDING; | 2006 | win_pos.x -= PADDING; |
| 2007 | + } else { | ||
| 2008 | + win_pos += self.working_area.loc; | ||
| 1986 | } | 2009 | } |
| 1987 | 2010 | ||
| 1988 | // Draw the window itself. | 2011 | // Draw the window itself. |
| @@ -2013,6 +2036,8 @@ impl Workspace<Window> { | |||
| 2013 | // FIXME: fullscreen windows are missing left padding | 2036 | // FIXME: fullscreen windows are missing left padding |
| 2014 | win_pos.x -= PADDING; | 2037 | win_pos.x -= PADDING; |
| 2015 | win_pos.y -= PADDING; | 2038 | win_pos.y -= PADDING; |
| 2039 | + } else { | ||
| 2040 | + win_pos += self.working_area.loc; | ||
| 2016 | } | 2041 | } |
| 2017 | 2042 | ||
| 2018 | rv.extend(win.render_elements( | 2043 | rv.extend(win.render_elements( |
| @@ -2034,7 +2059,11 @@ impl Workspace<Window> { | |||
| 2034 | } | 2059 | } |
| 2035 | 2060 | ||
| 2036 | impl<W: LayoutElement> Column<W> { | 2061 | impl<W: LayoutElement> Column<W> { |
| 2037 | - fn new(window: W, view_size: Size<i32, Logical>) -> Self { | 2062 | + fn new( |
| 2063 | + window: W, | ||
| 2064 | + view_size: Size<i32, Logical>, | ||
| 2065 | + working_area: Rectangle<i32, Logical>, | ||
| 2066 | + ) -> Self { | ||
| 2038 | let mut rv = Self { | 2067 | let mut rv = Self { |
| 2039 | windows: vec![], | 2068 | windows: vec![], |
| 2040 | active_window_idx: 0, | 2069 | active_window_idx: 0, |
| @@ -2042,7 +2071,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 2042 | is_fullscreen: false, | 2071 | is_fullscreen: false, |
| 2043 | }; | 2072 | }; |
| 2044 | 2073 | ||
| 2045 | - rv.add_window(view_size, window); | 2074 | + rv.add_window(view_size, working_area, window); |
| 2046 | 2075 | ||
| 2047 | rv | 2076 | rv |
| 2048 | } | 2077 | } |
| @@ -2051,9 +2080,14 @@ impl<W: LayoutElement> Column<W> { | |||
| 2051 | self.windows.len() | 2080 | self.windows.len() |
| 2052 | } | 2081 | } |
| 2053 | 2082 | ||
| 2054 | - fn set_width(&mut self, view_size: Size<i32, Logical>, width: ColumnWidth) { | 2083 | + fn set_width( |
| 2084 | + &mut self, | ||
| 2085 | + view_size: Size<i32, Logical>, | ||
| 2086 | + working_area: Rectangle<i32, Logical>, | ||
| 2087 | + width: ColumnWidth, | ||
| 2088 | + ) { | ||
| 2055 | self.width = width; | 2089 | self.width = width; |
| 2056 | - self.update_window_sizes(view_size); | 2090 | + self.update_window_sizes(view_size, working_area); |
| 2057 | } | 2091 | } |
| 2058 | 2092 | ||
| 2059 | fn contains(&self, window: &W) -> bool { | 2093 | fn contains(&self, window: &W) -> bool { |
| @@ -2065,13 +2099,22 @@ impl<W: LayoutElement> Column<W> { | |||
| 2065 | self.active_window_idx = idx; | 2099 | self.active_window_idx = idx; |
| 2066 | } | 2100 | } |
| 2067 | 2101 | ||
| 2068 | - fn add_window(&mut self, view_size: Size<i32, Logical>, window: W) { | 2102 | + fn add_window( |
| 2103 | + &mut self, | ||
| 2104 | + view_size: Size<i32, Logical>, | ||
| 2105 | + working_area: Rectangle<i32, Logical>, | ||
| 2106 | + window: W, | ||
| 2107 | + ) { | ||
| 2069 | self.is_fullscreen = false; | 2108 | self.is_fullscreen = false; |
| 2070 | self.windows.push(window); | 2109 | self.windows.push(window); |
| 2071 | - self.update_window_sizes(view_size); | 2110 | + self.update_window_sizes(view_size, working_area); |
| 2072 | } | 2111 | } |
| 2073 | 2112 | ||
| 2074 | - fn update_window_sizes(&mut self, view_size: Size<i32, Logical>) { | 2113 | + fn update_window_sizes( |
| 2114 | + &mut self, | ||
| 2115 | + view_size: Size<i32, Logical>, | ||
| 2116 | + working_area: Rectangle<i32, Logical>, | ||
| 2117 | + ) { | ||
| 2075 | if self.is_fullscreen { | 2118 | if self.is_fullscreen { |
| 2076 | self.windows[0].request_fullscreen(view_size); | 2119 | self.windows[0].request_fullscreen(view_size); |
| 2077 | return; | 2120 | return; |
| @@ -2105,8 +2148,8 @@ impl<W: LayoutElement> Column<W> { | |||
| 2105 | .unwrap_or(i32::MAX); | 2148 | .unwrap_or(i32::MAX); |
| 2106 | let max_width = max(max_width, min_width); | 2149 | let max_width = max(max_width, min_width); |
| 2107 | 2150 | ||
| 2108 | - let width = self.width.resolve(view_size.w - PADDING) - PADDING; | 2151 | + let width = self.width.resolve(working_area.size.w - PADDING) - PADDING; |
| 2109 | - let height = (view_size.h - PADDING) / self.window_count() as i32 - PADDING; | 2152 | + let height = (working_area.size.h - PADDING) / self.window_count() as i32 - PADDING; |
| 2110 | let size = Size::from((max(min(width, max_width), min_width), max(height, 1))); | 2153 | let size = Size::from((max(min(width, max_width), min_width), max(height, 1))); |
| 2111 | 2154 | ||
| 2112 | for win in &self.windows { | 2155 | for win in &self.windows { |
| @@ -2165,22 +2208,32 @@ impl<W: LayoutElement> Column<W> { | |||
| 2165 | } | 2208 | } |
| 2166 | } | 2209 | } |
| 2167 | 2210 | ||
| 2168 | - fn toggle_width(&mut self, view_size: Size<i32, Logical>) { | 2211 | + fn toggle_width( |
| 2212 | + &mut self, | ||
| 2213 | + view_size: Size<i32, Logical>, | ||
| 2214 | + working_area: Rectangle<i32, Logical>, | ||
| 2215 | + ) { | ||
| 2169 | let idx = match self.width { | 2216 | let idx = match self.width { |
| 2170 | ColumnWidth::PresetProportion(idx) => (idx + 1) % WIDTH_PROPORTIONS.len(), | 2217 | ColumnWidth::PresetProportion(idx) => (idx + 1) % WIDTH_PROPORTIONS.len(), |
| 2171 | _ => { | 2218 | _ => { |
| 2172 | let current = self.size().w; | 2219 | let current = self.size().w; |
| 2173 | WIDTH_PROPORTIONS | 2220 | WIDTH_PROPORTIONS |
| 2174 | .into_iter() | 2221 | .into_iter() |
| 2175 | - .position(|prop| prop.resolve(view_size.w - PADDING) - PADDING > current) | 2222 | + .position(|prop| { |
| 2223 | + prop.resolve(working_area.size.w - PADDING) - PADDING > current | ||
| 2224 | + }) | ||
| 2176 | .unwrap_or(0) | 2225 | .unwrap_or(0) |
| 2177 | } | 2226 | } |
| 2178 | }; | 2227 | }; |
| 2179 | let width = ColumnWidth::PresetProportion(idx); | 2228 | let width = ColumnWidth::PresetProportion(idx); |
| 2180 | - self.set_width(view_size, width); | 2229 | + self.set_width(view_size, working_area, width); |
| 2181 | } | 2230 | } |
| 2182 | 2231 | ||
| 2183 | - fn toggle_full_width(&mut self, view_size: Size<i32, Logical>) { | 2232 | + fn toggle_full_width( |
| 2233 | + &mut self, | ||
| 2234 | + view_size: Size<i32, Logical>, | ||
| 2235 | + working_area: Rectangle<i32, Logical>, | ||
| 2236 | + ) { | ||
| 2184 | let width = match self.width { | 2237 | let width = match self.width { |
| 2185 | ColumnWidth::Proportion(x) if x == 1. => { | 2238 | ColumnWidth::Proportion(x) if x == 1. => { |
| 2186 | // FIXME: would be good to restore to previous width here. | 2239 | // FIXME: would be good to restore to previous width here. |
| @@ -2188,13 +2241,18 @@ impl<W: LayoutElement> Column<W> { | |||
| 2188 | } | 2241 | } |
| 2189 | _ => ColumnWidth::Proportion(1.), | 2242 | _ => ColumnWidth::Proportion(1.), |
| 2190 | }; | 2243 | }; |
| 2191 | - self.set_width(view_size, width); | 2244 | + self.set_width(view_size, working_area, width); |
| 2192 | } | 2245 | } |
| 2193 | 2246 | ||
| 2194 | - fn set_fullscreen(&mut self, view_size: Size<i32, Logical>, is_fullscreen: bool) { | 2247 | + fn set_fullscreen( |
| 2248 | + &mut self, | ||
| 2249 | + view_size: Size<i32, Logical>, | ||
| 2250 | + working_area: Rectangle<i32, Logical>, | ||
| 2251 | + is_fullscreen: bool, | ||
| 2252 | + ) { | ||
| 2195 | assert_eq!(self.windows.len(), 1); | 2253 | assert_eq!(self.windows.len(), 1); |
| 2196 | self.is_fullscreen = is_fullscreen; | 2254 | self.is_fullscreen = is_fullscreen; |
| 2197 | - self.update_window_sizes(view_size); | 2255 | + self.update_window_sizes(view_size, working_area); |
| 2198 | } | 2256 | } |
| 2199 | 2257 | ||
| 2200 | fn window_y(&self, window_idx: usize) -> i32 { | 2258 | fn window_y(&self, window_idx: usize) -> i32 { |
| @@ -2222,12 +2280,15 @@ pub fn output_size(output: &Output) -> Size<i32, Logical> { | |||
| 2222 | .to_logical(output_scale) | 2280 | .to_logical(output_scale) |
| 2223 | } | 2281 | } |
| 2224 | 2282 | ||
| 2225 | -pub fn configure_new_window(view_size: Size<i32, Logical>, window: &Window) { | 2283 | +pub fn configure_new_window(working_area: Rectangle<i32, Logical>, window: &Window) { |
| 2226 | - let width = ColumnWidth::default().resolve(view_size.w - PADDING) - PADDING; | 2284 | + let width = ColumnWidth::default().resolve(working_area.size.w - PADDING) - PADDING; |
| 2227 | - let height = view_size.h - PADDING * 2; | 2285 | + let height = working_area.size.h - PADDING * 2; |
| 2228 | let size = Size::from((max(width, 1), max(height, 1))); | 2286 | let size = Size::from((max(width, 1), max(height, 1))); |
| 2229 | 2287 | ||
| 2230 | - let bounds = Size::from((view_size.w - PADDING * 2, view_size.h - PADDING * 2)); | 2288 | + let bounds = Size::from(( |
| 2289 | + working_area.size.w - PADDING * 2, | ||
| 2290 | + working_area.size.h - PADDING * 2, | ||
| 2291 | + )); | ||
| 2231 | 2292 | ||
| 2232 | window.toplevel().with_pending_state(|state| { | 2293 | window.toplevel().with_pending_state(|state| { |
| 2233 | state.size = Some(size); | 2294 | state.size = Some(size); |
src/niri.rsmodified+2 -1
| @@ -662,8 +662,8 @@ impl Niri { | |||
| 662 | } | 662 | } |
| 663 | 663 | ||
| 664 | pub fn output_resized(&mut self, output: Output) { | 664 | pub fn output_resized(&mut self, output: Output) { |
| 665 | - self.monitor_set.update_output(&output); | ||
| 666 | layer_map_for_output(&output).arrange(); | 665 | layer_map_for_output(&output).arrange(); |
| 666 | + self.monitor_set.update_output_size(&output); | ||
| 667 | self.queue_redraw(output); | 667 | self.queue_redraw(output); |
| 668 | } | 668 | } |
| 669 | 669 | ||
| @@ -916,6 +916,7 @@ impl Niri { | |||
| 916 | } | 916 | } |
| 917 | 917 | ||
| 918 | // Then the upper layer-shell elements. | 918 | // Then the upper layer-shell elements. |
| 919 | + // FIXME: hide top layer when a fullscreen surface is showing somehow. | ||
| 919 | elements.extend( | 920 | elements.extend( |
| 920 | upper | 921 | upper |
| 921 | .into_iter() | 922 | .into_iter() |