formatting fixes

This commit is contained in:
Victoria Brekenfeld 2023-12-20 20:51:04 +00:00 committed by Victoria Brekenfeld
parent 0ac12ce202
commit f928f80f09
4 changed files with 144 additions and 143 deletions

View file

@ -600,7 +600,7 @@ impl State {
let under = let under =
State::surface_under(position, &current_output, &mut self.common.shell) State::surface_under(position, &current_output, &mut self.common.shell)
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
let ptr = seat.get_pointer().unwrap(); let ptr = seat.get_pointer().unwrap();
@ -674,7 +674,7 @@ impl State {
let output_geometry = output.geometry(); let output_geometry = output.geometry();
let new_under = State::surface_under(position, &output, &mut self.common.shell) let new_under = State::surface_under(position, &output, &mut self.common.shell)
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
position.x = position.x.clamp( position.x = position.x.clamp(
output_geometry.loc.x as f64, output_geometry.loc.x as f64,
@ -791,7 +791,7 @@ impl State {
.as_global(); .as_global();
let serial = SERIAL_COUNTER.next_serial(); let serial = SERIAL_COUNTER.next_serial();
let under = State::surface_under(position, &output, &mut self.common.shell) let under = State::surface_under(position, &output, &mut self.common.shell)
.map(|(target, pos)| (target, pos.as_logical())); .map(|(target, pos)| (target, pos.as_logical()));
for session in sessions_for_output(&self.common, &output) { for session in sessions_for_output(&self.common, &output) {
if let Some((geometry, offset)) = seat.cursor_geometry( if let Some((geometry, offset)) = seat.cursor_geometry(

View file

@ -308,20 +308,20 @@ impl Program for CosmicWindowInternal {
return; return;
}; };
let mut cursor = seat let mut cursor = seat
.get_pointer() .get_pointer()
.unwrap() .unwrap()
.current_location() .current_location()
.to_i32_round(); .to_i32_round();
cursor.y -= SSD_HEIGHT; cursor.y -= SSD_HEIGHT;
Shell::menu_request( Shell::menu_request(
state, state,
&surface, &surface,
&seat, &seat,
serial, serial,
cursor - position.as_logical(), cursor - position.as_logical(),
false, false,
); );
} }
}); });
} }

View file

@ -121,18 +121,18 @@ impl Shell {
workspace.unwrap() workspace.unwrap()
}; };
let mut focus_stack = workspace.focus_stack.get_mut(active_seat); let mut focus_stack = workspace.focus_stack.get_mut(active_seat);
if Some(&mapped) != focus_stack.last() { if Some(&mapped) != focus_stack.last() {
trace!(?mapped, "Focusing window."); trace!(?mapped, "Focusing window.");
focus_stack.append(&mapped); focus_stack.append(&mapped);
// also remove popup grabs, if we are switching focus // also remove popup grabs, if we are switching focus
if let Some(mut popup_grab) = active_seat if let Some(mut popup_grab) = active_seat
.user_data() .user_data()
.get::<PopupGrabData>() .get::<PopupGrabData>()
.and_then(|x| x.take()) .and_then(|x| x.take())
{ {
if !popup_grab.has_ended() { if !popup_grab.has_ended() {
popup_grab.ungrab(PopupUngrabStrategy::All); popup_grab.ungrab(PopupUngrabStrategy::All);
} }
} }
} }

View file

@ -365,6 +365,7 @@ impl WorkspaceSet {
state.remove_workspace_state(&self.workspaces[old_active].handle, WState::Urgent); state.remove_workspace_state(&self.workspaces[old_active].handle, WState::Urgent);
state.remove_workspace_state(&self.workspaces[idx].handle, WState::Urgent); state.remove_workspace_state(&self.workspaces[idx].handle, WState::Urgent);
state.add_workspace_state(&self.workspaces[idx].handle, WState::Active); state.add_workspace_state(&self.workspaces[idx].handle, WState::Active);
self.previously_active = Some((old_active, Instant::now())); self.previously_active = Some((old_active, Instant::now()));
self.active = idx; self.active = idx;
Ok(true) Ok(true)
@ -1219,17 +1220,17 @@ impl Shell {
// override redirect window? // override redirect window?
.or_else(|| { .or_else(|| {
self.outputs().find(|o| { self.outputs().find(|o| {
self.override_redirect_windows.iter().any(|or| { self.override_redirect_windows.iter().any(|or| {
if or.wl_surface().as_ref() == Some(surface) { if or.wl_surface().as_ref() == Some(surface) {
or.geometry() or.geometry()
.as_global() .as_global()
.intersection(o.geometry()) .intersection(o.geometry())
.is_some() .is_some()
} else { } else {
false false
} }
})
}) })
})
}) })
// sticky window ? // sticky window ?
.or_else(|| { .or_else(|| {
@ -1280,7 +1281,7 @@ impl Shell {
.or_else(|| { .or_else(|| {
set.workspaces set.workspaces
.iter() .iter()
.find_map(|w| w.element_for_surface(surface)) .find_map(|w| w.element_for_surface(surface))
}) })
}) })
} }
@ -1296,7 +1297,7 @@ impl Shell {
.or_else(|| { .or_else(|| {
set.workspaces set.workspaces
.iter() .iter()
.find_map(|w| w.element_for_wl_surface(surface)) .find_map(|w| w.element_for_wl_surface(surface))
}) })
}) })
} }
@ -2049,10 +2050,10 @@ impl Shell {
check_grab_preconditions(&seat, surface, serial, ReleaseMode::NoMouseButtons) check_grab_preconditions(&seat, surface, serial, ReleaseMode::NoMouseButtons)
{ {
if let Some(mapped) = state.common.shell.element_for_wl_surface(surface).cloned() { if let Some(mapped) = state.common.shell.element_for_wl_surface(surface).cloned() {
let (_, relative_loc) = mapped let (_, relative_loc) = mapped
.windows() .windows()
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface)) .find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
.unwrap(); .unwrap();
let (global_position, edge, is_tiled, is_stacked, is_sticky, tiling_enabled) = let (global_position, edge, is_tiled, is_stacked, is_sticky, tiling_enabled) =
if let Some(set) = state if let Some(set) = state
@ -2080,27 +2081,27 @@ impl Shell {
} else if let Some(workspace) = state.common.shell.space_for_mut(&mapped) { } else if let Some(workspace) = state.common.shell.space_for_mut(&mapped) {
let output = seat.active_output(); let output = seat.active_output();
let global_position = (workspace.element_geometry(&mapped).unwrap().loc let global_position = (workspace.element_geometry(&mapped).unwrap().loc
+ relative_loc.as_local() + relative_loc.as_local()
+ location.as_local()) + location.as_local())
.to_global(&output); .to_global(&output);
let is_tiled = workspace.is_tiled(&mapped); let is_tiled = workspace.is_tiled(&mapped);
let edge = if is_tiled { let edge = if is_tiled {
mapped mapped
.tiling_node_id .tiling_node_id
.lock() .lock()
.unwrap() .unwrap()
.clone() .clone()
.map(|node_id| { .map(|node_id| {
TilingLayout::possible_resizes( TilingLayout::possible_resizes(
workspace.tiling_layer.tree(), workspace.tiling_layer.tree(),
node_id, node_id,
) )
}) })
.unwrap_or(ResizeEdge::empty()) .unwrap_or(ResizeEdge::empty())
} else { } else {
ResizeEdge::all() ResizeEdge::all()
}; };
( (
global_position, global_position,
@ -2114,41 +2115,41 @@ impl Shell {
return; return;
}; };
let grab = MenuGrab::new( let grab = MenuGrab::new(
start_data, start_data,
seat, seat,
if target_stack || !is_stacked { if target_stack || !is_stacked {
Box::new(window_items( Box::new(window_items(
&mapped, &mapped,
is_tiled, is_tiled,
is_stacked, is_stacked,
is_sticky, is_sticky,
tiling_enabled, tiling_enabled,
edge, edge,
&state.common.config.static_conf, &state.common.config.static_conf,
)) as Box<dyn Iterator<Item = Item>> )) as Box<dyn Iterator<Item = Item>>
} else { } else {
let (tab, _) = mapped let (tab, _) = mapped
.windows() .windows()
.find(|(s, _)| s.wl_surface().as_ref() == Some(surface)) .find(|(s, _)| s.wl_surface().as_ref() == Some(surface))
.unwrap(); .unwrap();
Box::new(tab_items( Box::new(tab_items(
&mapped, &mapped,
&tab, &tab,
is_tiled, is_tiled,
&state.common.config.static_conf, &state.common.config.static_conf,
)) as Box<dyn Iterator<Item = Item>> )) as Box<dyn Iterator<Item = Item>>
}, },
global_position, global_position,
state.common.event_loop_handle.clone(), state.common.event_loop_handle.clone(),
state.common.theme.clone(), state.common.theme.clone(),
); );
seat.get_pointer().unwrap().set_grab( seat.get_pointer().unwrap().set_grab(
state, state,
grab, grab,
serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial()), serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial()),
Focus::Keep, Focus::Keep,
); );
} }
} }
} }
@ -2162,7 +2163,7 @@ impl Shell {
move_out_of_stack: bool, move_out_of_stack: bool,
) { ) {
let serial = serial.into(); let serial = serial.into();
let output = seat.active_output(); let output = seat.active_output();
if let Some(mut start_data) = check_grab_preconditions(&seat, surface, serial, release) { if let Some(mut start_data) = check_grab_preconditions(&seat, surface, serial, release) {
if let Some(mut old_mapped) = if let Some(mut old_mapped) =
@ -2177,9 +2178,9 @@ impl Shell {
} }
let (window, _) = old_mapped let (window, _) = old_mapped
.windows() .windows()
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface)) .find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
.unwrap(); .unwrap();
let mapped = if move_out_of_stack { let mapped = if move_out_of_stack {
let new_mapped: CosmicMapped = CosmicWindow::new( let new_mapped: CosmicMapped = CosmicWindow::new(
@ -2194,8 +2195,8 @@ impl Shell {
old_mapped.clone() old_mapped.clone()
}; };
let button = start_data.button; let button = start_data.button;
let active_hint = state.common.theme.cosmic().active_hint as u8; let active_hint = state.common.theme.cosmic().active_hint as u8;
let pointer = seat.get_pointer().unwrap(); let pointer = seat.get_pointer().unwrap();
let pos = pointer.current_location().as_global(); let pos = pointer.current_location().as_global();
@ -2285,16 +2286,16 @@ impl Shell {
return; return;
}; };
state state
.common .common
.shell .shell
.toplevel_info_state .toplevel_info_state
.toplevel_leave_workspace(&window, &workspace_handle); .toplevel_leave_workspace(&window, &workspace_handle);
state state
.common .common
.shell .shell
.toplevel_info_state .toplevel_info_state
.toplevel_leave_output(&window, &output); .toplevel_leave_output(&window, &output);
if move_out_of_stack { if move_out_of_stack {
old_mapped.stack_ref_mut().unwrap().remove_window(&window); old_mapped.stack_ref_mut().unwrap().remove_window(&window);
@ -2319,19 +2320,19 @@ impl Shell {
state.common.event_loop_handle.clone(), state.common.event_loop_handle.clone(),
); );
if grab.is_tiling_grab() { if grab.is_tiling_grab() {
state.common.shell.set_overview_mode( state.common.shell.set_overview_mode(
Some(Trigger::Pointer(button)), Some(Trigger::Pointer(button)),
state.common.event_loop_handle.clone(), state.common.event_loop_handle.clone(),
); );
} }
seat.get_pointer().unwrap().set_grab( seat.get_pointer().unwrap().set_grab(
state, state,
grab, grab,
serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial()), serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial()),
Focus::Clear, Focus::Clear,
); );
} }
} }
} }
@ -2514,12 +2515,12 @@ impl Shell {
edges, edges,
ReleaseMode::NoMouseButtons, ReleaseMode::NoMouseButtons,
) { ) {
seat.get_pointer().unwrap().set_grab( seat.get_pointer().unwrap().set_grab(
state, state,
grab, grab,
serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial()), serial.unwrap_or_else(|| SERIAL_COUNTER.next_serial()),
Focus::Clear, Focus::Clear,
); );
} }
} }
} }
@ -2531,13 +2532,13 @@ impl Shell {
let Some(focused) = seat.get_keyboard().unwrap().current_focus() else { let Some(focused) = seat.get_keyboard().unwrap().current_focus() else {
return; return;
}; };
let amount = (self let amount = (self
.resize_state .resize_state
.take() .take()
.map(|(_, _, _, amount, _, _)| amount) .map(|(_, _, _, amount, _, _)| amount)
.unwrap_or(10) .unwrap_or(10)
+ 2) + 2)
.min(20); .min(20);
if self if self
.workspaces .workspaces
@ -2570,9 +2571,9 @@ impl Shell {
.or_else(|| { .or_else(|| {
let workspace = self.workspaces.get(idx, &output).unwrap(); let workspace = self.workspaces.get(idx, &output).unwrap();
workspace workspace
.mapped() .mapped()
.find(|m| m.has_surface(&toplevel, WindowSurfaceType::TOPLEVEL)) .find(|m| m.has_surface(&toplevel, WindowSurfaceType::TOPLEVEL))
.cloned() .cloned()
}) })
else { else {
return return