shell: Allow overview to be triggered by pointer

This commit is contained in:
Victoria Brekenfeld 2023-07-17 21:11:45 +02:00
parent a8a5ee466a
commit f00dda7591
2 changed files with 28 additions and 7 deletions

View file

@ -8,7 +8,7 @@ use crate::{
layout::{ layout::{
tiling::{Direction, FocusResult, MoveResult}, tiling::{Direction, FocusResult, MoveResult},
}, },
OverviewMode, ResizeDirection, ResizeMode, Workspace, OverviewMode, ResizeDirection, ResizeMode, Workspace, Trigger,
}, // shell::grabs::SeatMoveGrabState }, // shell::grabs::SeatMoveGrabState
state::Common, state::Common,
utils::prelude::*, utils::prelude::*,
@ -251,7 +251,7 @@ impl State {
time, time,
|data, modifiers, handle| { |data, modifiers, handle| {
// Leave overview mode, if any modifier was released // Leave overview mode, if any modifier was released
if let OverviewMode::Started(action_modifiers, _) = if let OverviewMode::Started(Trigger::Keyboard(action_modifiers), _) =
data.common.shell.overview_mode() data.common.shell.overview_mode()
{ {
if (action_modifiers.ctrl && !modifiers.ctrl) if (action_modifiers.ctrl && !modifiers.ctrl)
@ -687,6 +687,14 @@ impl State {
} }
Common::set_focus(self, under.and_then(|target| target.try_into().ok()).as_ref(), seat, Some(serial)); Common::set_focus(self, under.and_then(|target| target.try_into().ok()).as_ref(), seat, Some(serial));
} }
} else {
if let OverviewMode::Started(Trigger::Pointer(action_button), _) =
self.common.shell.overview_mode()
{
if action_button == button {
self.common.shell.set_overview_mode(None);
}
}
}; };
seat.get_pointer().unwrap().button( seat.get_pointer().unwrap().button(
self, self,
@ -1214,7 +1222,7 @@ impl State {
MoveResult::Done => { MoveResult::Done => {
if let Some(focused_window) = workspace.focus_stack.get(seat).last() { if let Some(focused_window) = workspace.focus_stack.get(seat).last() {
if workspace.is_tiled(focused_window) { if workspace.is_tiled(focused_window) {
self.common.shell.set_overview_mode(Some(pattern.modifiers)); self.common.shell.set_overview_mode(Some(Trigger::Keyboard(pattern.modifiers)));
} }
} }
} }

View file

@ -70,10 +70,16 @@ use self::{
const ANIMATION_DURATION: Duration = Duration::from_millis(200); const ANIMATION_DURATION: Duration = Duration::from_millis(200);
#[derive(Debug, Clone)]
pub enum Trigger {
Keyboard(KeyModifiers),
Pointer(u32),
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum OverviewMode { pub enum OverviewMode {
None, None,
Started(KeyModifiers, Instant), Started(Trigger, Instant),
Ended(Instant), Ended(Instant),
} }
@ -1205,10 +1211,10 @@ impl Shell {
clients clients
} }
pub fn set_overview_mode(&mut self, enabled: Option<KeyModifiers>) { pub fn set_overview_mode(&mut self, enabled: Option<Trigger>) {
if let Some(modifiers) = enabled { if let Some(trigger) = enabled {
if !matches!(self.overview_mode, OverviewMode::Started(_, _)) { if !matches!(self.overview_mode, OverviewMode::Started(_, _)) {
self.overview_mode = OverviewMode::Started(modifiers, Instant::now()); self.overview_mode = OverviewMode::Started(trigger, Instant::now());
} }
} else { } else {
if !matches!(self.overview_mode, OverviewMode::Ended(_)) { if !matches!(self.overview_mode, OverviewMode::Ended(_)) {
@ -1545,6 +1551,7 @@ impl Shell {
.windows() .windows()
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface)) .find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
.unwrap(); .unwrap();
let button = start_data.button;
if let Some(grab) = workspace.move_request( if let Some(grab) = workspace.move_request(
&window, &window,
&seat, &seat,
@ -1563,6 +1570,12 @@ impl Shell {
.shell .shell
.toplevel_info_state .toplevel_info_state
.toplevel_leave_output(&window, &output); .toplevel_leave_output(&window, &output);
if grab.is_tiling_grab() {
state
.common
.shell
.set_overview_mode(Some(Trigger::Pointer(button)));
}
seat.get_pointer().unwrap().set_grab( seat.get_pointer().unwrap().set_grab(
state, state,
grab, grab,