Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions src/input/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,26 +873,22 @@ impl State {
}

Action::Minimize => {
let Some(focused_output) = seat.focused_output() else {
return;
};
let mut shell = self.common.shell.write();
let workspace = shell.active_space_mut(&focused_output).unwrap();
let focus_stack = workspace.focus_stack.get(seat);
if let Some(surface) = focus_stack.last().and_then(FocusTarget::wl_surface) {
shell.minimize_request(&surface);
if let Some(focused_window) = seat
.get_keyboard()
.unwrap()
.current_focus()
.and_then(|f| f.active_window())
{
shell.minimize_request(&focused_window);
}
}

Action::Maximize => {
let Some(focused_output) = seat.focused_output() else {
return;
};
let mut shell = self.common.shell.write();
let workspace = shell.active_space(&focused_output).unwrap();
let focus_stack = workspace.focus_stack.get(seat);
let focused_window = focus_stack.last().cloned();
if let Some(FocusTarget::Window(window)) = focused_window {
if let Some(KeyboardFocusTarget::Element(window)) =
seat.get_keyboard().unwrap().current_focus()
{
shell.maximize_toggle(&window, seat, &self.common.event_loop_handle);
}
}
Expand All @@ -902,22 +898,18 @@ impl State {
return;
};
let mut shell = self.common.shell.write();
let workspace = shell.active_space(&focused_output).unwrap();
let focus_stack = workspace.focus_stack.get(seat);
let focused_window = focus_stack.last().cloned();
match focused_window {
Some(FocusTarget::Window(window)) => {
let output = workspace.output.clone();
match seat.get_keyboard().unwrap().current_focus() {
Some(KeyboardFocusTarget::Element(window)) => {
if let Some(target) = shell.fullscreen_request(
&window.active_window(),
output,
focused_output,
&self.common.event_loop_handle,
) {
std::mem::drop(shell);
Shell::set_focus(self, Some(&target), seat, Some(serial), true);
}
}
Some(FocusTarget::Fullscreen(surface)) => {
Some(KeyboardFocusTarget::Fullscreen(surface)) => {
if let Some(target) =
shell.unfullscreen_request(&surface, &self.common.event_loop_handle)
{
Expand Down
8 changes: 8 additions & 0 deletions src/shell/focus/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ impl KeyboardFocusTarget {
}
}

pub fn active_window(&self) -> Option<CosmicSurface> {
match self {
KeyboardFocusTarget::Element(mapped) => Some(mapped.active_window()),
KeyboardFocusTarget::Fullscreen(surface) => Some(surface.clone()),
_ => None,
}
}

pub fn is_xwm(&self, xwm: XwmId) -> bool {
match self {
KeyboardFocusTarget::Element(mapped) => {
Expand Down
3 changes: 1 addition & 2 deletions src/shell/seats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ impl SeatExt for Seat<State> {
}

/// Returns the output that contains the cursor associated with a seat. Note that the window which has keyboard focus
/// may be on a different output. Currently, to get the focused output, first get the keyboard focus target and pass
/// it to get_focused_output in the shell.
/// may be on a different output. Currently, to get the focused output, use [`Self::focused_output`].
fn active_output(&self) -> Output {
self.user_data()
.get::<ActiveOutput>()
Expand Down
Loading