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::{
tiling::{Direction, FocusResult, MoveResult},
},
OverviewMode, ResizeDirection, ResizeMode, Workspace,
OverviewMode, ResizeDirection, ResizeMode, Workspace, Trigger,
}, // shell::grabs::SeatMoveGrabState
state::Common,
utils::prelude::*,
@ -251,7 +251,7 @@ impl State {
time,
|data, modifiers, handle| {
// 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()
{
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));
}
} 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(
self,
@ -1214,7 +1222,7 @@ impl State {
MoveResult::Done => {
if let Some(focused_window) = workspace.focus_stack.get(seat).last() {
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);
#[derive(Debug, Clone)]
pub enum Trigger {
Keyboard(KeyModifiers),
Pointer(u32),
}
#[derive(Debug, Clone)]
pub enum OverviewMode {
None,
Started(KeyModifiers, Instant),
Started(Trigger, Instant),
Ended(Instant),
}
@ -1205,10 +1211,10 @@ impl Shell {
clients
}
pub fn set_overview_mode(&mut self, enabled: Option<KeyModifiers>) {
if let Some(modifiers) = enabled {
pub fn set_overview_mode(&mut self, enabled: Option<Trigger>) {
if let Some(trigger) = enabled {
if !matches!(self.overview_mode, OverviewMode::Started(_, _)) {
self.overview_mode = OverviewMode::Started(modifiers, Instant::now());
self.overview_mode = OverviewMode::Started(trigger, Instant::now());
}
} else {
if !matches!(self.overview_mode, OverviewMode::Ended(_)) {
@ -1545,6 +1551,7 @@ impl Shell {
.windows()
.find(|(w, _)| w.wl_surface().as_ref() == Some(surface))
.unwrap();
let button = start_data.button;
if let Some(grab) = workspace.move_request(
&window,
&seat,
@ -1563,6 +1570,12 @@ impl Shell {
.shell
.toplevel_info_state
.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(
state,
grab,