Refactor window ownership and immutable frame sampling
This commit is contained in:
1 parent
c0010ccbb6
commit
07bda5a21c
31 files changed
+1222
-623
No files matched your search
@@ -43,7 +43,7 @@ impl XdgActivationHandler for Ferese {
|
||||
return;
|
||||
};
|
||||
|
||||
self.focused_window = self.window_ids.get(&window).copied();
|
||||
self.focused_window = self.windows.ids().get(&window).copied();
|
||||
if let Some(focused) = self.focused_window
|
||||
&& let Err(error) = self.workspaces.focus_window(focused)
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ impl CompositorHandler for Ferese {
|
||||
if surface == &root {
|
||||
if crate::state::window_has_buffer(&window) {
|
||||
xdg_shell::apply_initial_window_rules(self, &window);
|
||||
} else if self.window_ids.contains_key(&window) {
|
||||
} else if self.windows.ids().contains_key(&window) {
|
||||
self.remove_tiled_window(&window);
|
||||
self.space.map_element(window.clone(), (0, 0), false);
|
||||
self.restore_keyboard_focus();
|
||||
|
||||
@@ -60,7 +60,7 @@ impl SeatHandler for Ferese {
|
||||
|
||||
fn focus_changed(&mut self, seat: &Seat<Self>, focused: Option<&WlSurface>) {
|
||||
if let Some(id) = focused.and_then(|surface| {
|
||||
self.window_ids.iter().find_map(|(window, id)| {
|
||||
self.windows.ids().iter().find_map(|(window, id)| {
|
||||
window
|
||||
.toplevel()
|
||||
.is_some_and(|toplevel| toplevel.wl_surface() == surface)
|
||||
@@ -152,7 +152,7 @@ impl Ferese {
|
||||
{
|
||||
root = parent;
|
||||
}
|
||||
let window = self.window_ids.iter().find_map(|(window, id)| {
|
||||
let window = self.windows.ids().iter().find_map(|(window, id)| {
|
||||
window
|
||||
.toplevel()
|
||||
.is_some_and(|toplevel| toplevel.wl_surface() == &root)
|
||||
|
||||
@@ -186,7 +186,8 @@ impl Ferese {
|
||||
return None;
|
||||
}
|
||||
let window = self
|
||||
.window_ids
|
||||
.windows
|
||||
.ids()
|
||||
.iter()
|
||||
.find(|(_, candidate)| **candidate == id)?
|
||||
.0
|
||||
@@ -283,7 +284,7 @@ pub(super) fn copy_snapshot(state: &Ferese, resource: &ZwlrScreencopyFrameV1, da
|
||||
};
|
||||
if state.session_lock.active
|
||||
|| !super::screencopy::capture_allowed()
|
||||
|| !state.window_ids.values().any(|id| *id == snapshot.id)
|
||||
|| !state.windows.ids().values().any(|id| *id == snapshot.id)
|
||||
{
|
||||
resource.failed();
|
||||
return;
|
||||
|
||||
@@ -36,7 +36,7 @@ impl XdgShellHandler for Ferese {
|
||||
let Some(parent) = surface.parent() else {
|
||||
return;
|
||||
};
|
||||
let parent = self.window_ids.iter().find_map(|(window, id)| {
|
||||
let parent = self.windows.ids().iter().find_map(|(window, id)| {
|
||||
window
|
||||
.toplevel()
|
||||
.is_some_and(|toplevel| toplevel.wl_surface() == &parent)
|
||||
@@ -60,7 +60,8 @@ impl XdgShellHandler for Ferese {
|
||||
fn toplevel_destroyed(&mut self, surface: ToplevelSurface) {
|
||||
// Hidden workspace windows are managed but unmapped from Space.
|
||||
let Some(window) = self
|
||||
.window_ids
|
||||
.windows
|
||||
.ids()
|
||||
.keys()
|
||||
.chain(self.space.elements())
|
||||
.find(|window| {
|
||||
@@ -185,7 +186,7 @@ impl XdgShellHandler for Ferese {
|
||||
}
|
||||
|
||||
fn maximize_request(&mut self, surface: ToplevelSurface) {
|
||||
if let Some(id) = self.window_ids.iter().find_map(|(window, id)| {
|
||||
if let Some(id) = self.windows.ids().iter().find_map(|(window, id)| {
|
||||
window
|
||||
.toplevel()
|
||||
.is_some_and(|toplevel| toplevel.wl_surface() == surface.wl_surface())
|
||||
@@ -198,7 +199,7 @@ impl XdgShellHandler for Ferese {
|
||||
}
|
||||
|
||||
fn unmaximize_request(&mut self, surface: ToplevelSurface) {
|
||||
if let Some(id) = self.window_ids.iter().find_map(|(window, id)| {
|
||||
if let Some(id) = self.windows.ids().iter().find_map(|(window, id)| {
|
||||
window
|
||||
.toplevel()
|
||||
.is_some_and(|toplevel| toplevel.wl_surface() == surface.wl_surface())
|
||||
@@ -215,7 +216,7 @@ impl XdgShellHandler for Ferese {
|
||||
surface: ToplevelSurface,
|
||||
_output: Option<smithay::reexports::wayland_server::protocol::wl_output::WlOutput>,
|
||||
) {
|
||||
if let Some(window) = self.window_ids.iter().find_map(|(window, id)| {
|
||||
if let Some(window) = self.windows.ids().iter().find_map(|(window, id)| {
|
||||
window
|
||||
.toplevel()
|
||||
.is_some_and(|toplevel| toplevel.wl_surface() == surface.wl_surface())
|
||||
@@ -228,7 +229,7 @@ impl XdgShellHandler for Ferese {
|
||||
}
|
||||
|
||||
fn unfullscreen_request(&mut self, surface: ToplevelSurface) {
|
||||
if let Some(window) = self.window_ids.iter().find_map(|(window, id)| {
|
||||
if let Some(window) = self.windows.ids().iter().find_map(|(window, id)| {
|
||||
window
|
||||
.toplevel()
|
||||
.is_some_and(|toplevel| toplevel.wl_surface() == surface.wl_surface())
|
||||
@@ -380,7 +381,7 @@ pub fn apply_initial_window_rules(state: &mut Ferese, window: &Window) {
|
||||
)
|
||||
});
|
||||
|
||||
let initial = !state.window_ids.contains_key(window);
|
||||
let initial = !state.windows.ids().contains_key(window);
|
||||
let requested = initial.then(|| {
|
||||
toplevel.with_pending_state(|pending| {
|
||||
(
|
||||
@@ -391,7 +392,7 @@ pub fn apply_initial_window_rules(state: &mut Ferese, window: &Window) {
|
||||
});
|
||||
if initial {
|
||||
let parent = toplevel.parent().and_then(|parent| {
|
||||
state.window_ids.iter().find_map(|(candidate, id)| {
|
||||
state.windows.ids().iter().find_map(|(candidate, id)| {
|
||||
candidate
|
||||
.toplevel()
|
||||
.is_some_and(|surface| surface.wl_surface() == &parent)
|
||||
@@ -402,7 +403,7 @@ pub fn apply_initial_window_rules(state: &mut Ferese, window: &Window) {
|
||||
}
|
||||
state.apply_initial_window_rules(window, app_id.as_deref(), title.as_deref(), transient);
|
||||
if let Some((maximized, fullscreen)) = requested
|
||||
&& let Some(id) = state.window_ids.get(window).copied()
|
||||
&& let Some(id) = state.windows.ids().get(window).copied()
|
||||
{
|
||||
if maximized {
|
||||
state.set_window_maximized(id, true);
|
||||
@@ -424,7 +425,7 @@ impl Ferese {
|
||||
.find(|window| window.toplevel().is_some_and(|toplevel| toplevel.wl_surface() == &root));
|
||||
let geometry = (|| {
|
||||
if let Some(window) = window {
|
||||
let id = *self.window_ids.get(window)?;
|
||||
let id = *self.windows.ids().get(window)?;
|
||||
let output = self
|
||||
.space
|
||||
.outputs()
|
||||
|
||||
Reference in new issue
Block a user