input: Add resize mode actions
This commit is contained in:
parent
7338ac8c57
commit
8c52fc6eb1
3 changed files with 75 additions and 20 deletions
|
|
@ -1,7 +1,9 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::{
|
||||
shell::{focus::FocusDirection, layout::tiling::Direction, Shell, WorkspaceAmount},
|
||||
shell::{
|
||||
focus::FocusDirection, layout::tiling::Direction, ResizeDirection, Shell, WorkspaceAmount,
|
||||
},
|
||||
state::{BackendData, Data, State},
|
||||
wayland::protocols::output_configuration::OutputConfigurationState,
|
||||
};
|
||||
|
|
@ -1015,6 +1017,7 @@ pub enum Action {
|
|||
ToggleTiling,
|
||||
ToggleWindowFloating,
|
||||
|
||||
Resizing(ResizeDirection),
|
||||
Maximize,
|
||||
Spawn(String),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::{
|
||||
config::{Action, Config, KeyModifiers, WorkspaceLayout},
|
||||
config::{Action, Config, KeyPattern, WorkspaceLayout},
|
||||
shell::{
|
||||
focus::{target::PointerFocusTarget, FocusDirection},
|
||||
layout::{
|
||||
|
|
@ -219,7 +219,7 @@ impl State {
|
|||
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
let time = Event::time_msec(&event);
|
||||
if let Some((action, mods)) = seat
|
||||
if let Some((action, pattern)) = seat
|
||||
.get_keyboard()
|
||||
.unwrap()
|
||||
.input(
|
||||
|
|
@ -297,7 +297,7 @@ impl State {
|
|||
.add(&handle);
|
||||
return FilterResult::Intercept(Some((
|
||||
action.clone(),
|
||||
binding.modifiers.clone(),
|
||||
binding.clone(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ impl State {
|
|||
)
|
||||
.flatten()
|
||||
{
|
||||
self.handle_action(action, seat, serial, time, mods, None)
|
||||
self.handle_action(action, seat, serial, time, pattern, None)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -659,7 +659,7 @@ impl State {
|
|||
seat: &Seat<State>,
|
||||
serial: Serial,
|
||||
time: u32,
|
||||
mods: KeyModifiers,
|
||||
pattern: KeyPattern,
|
||||
direction: Option<Direction>,
|
||||
) {
|
||||
match action {
|
||||
|
|
@ -717,7 +717,7 @@ impl State {
|
|||
.activate(¤t_output, workspace)
|
||||
.is_err()
|
||||
{
|
||||
self.handle_action(Action::NextOutput, seat, serial, time, mods, direction);
|
||||
self.handle_action(Action::NextOutput, seat, serial, time, pattern, direction);
|
||||
}
|
||||
}
|
||||
Action::PreviousWorkspace => {
|
||||
|
|
@ -735,7 +735,14 @@ impl State {
|
|||
.activate(¤t_output, workspace)
|
||||
.is_err()
|
||||
{
|
||||
self.handle_action(Action::PreviousOutput, seat, serial, time, mods, direction);
|
||||
self.handle_action(
|
||||
Action::PreviousOutput,
|
||||
seat,
|
||||
serial,
|
||||
time,
|
||||
pattern,
|
||||
direction,
|
||||
);
|
||||
}
|
||||
}
|
||||
Action::LastWorkspace => {
|
||||
|
|
@ -793,7 +800,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
direction,
|
||||
)
|
||||
}
|
||||
|
|
@ -827,7 +834,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
direction,
|
||||
)
|
||||
}
|
||||
|
|
@ -998,7 +1005,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
direction,
|
||||
),
|
||||
(FocusDirection::Right, WorkspaceLayout::Horizontal)
|
||||
|
|
@ -1008,7 +1015,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
direction,
|
||||
),
|
||||
(FocusDirection::Left, WorkspaceLayout::Vertical)
|
||||
|
|
@ -1018,7 +1025,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
direction,
|
||||
),
|
||||
(FocusDirection::Right, WorkspaceLayout::Vertical)
|
||||
|
|
@ -1028,7 +1035,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
direction,
|
||||
),
|
||||
_ => {}
|
||||
|
|
@ -1057,7 +1064,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
Some(direction),
|
||||
),
|
||||
(Direction::Right, WorkspaceLayout::Horizontal)
|
||||
|
|
@ -1066,7 +1073,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
Some(direction),
|
||||
),
|
||||
(Direction::Left, WorkspaceLayout::Vertical)
|
||||
|
|
@ -1075,7 +1082,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
Some(direction),
|
||||
),
|
||||
(Direction::Right, WorkspaceLayout::Vertical)
|
||||
|
|
@ -1084,7 +1091,7 @@ impl State {
|
|||
seat,
|
||||
serial,
|
||||
time,
|
||||
mods,
|
||||
pattern,
|
||||
Some(direction),
|
||||
),
|
||||
}
|
||||
|
|
@ -1095,7 +1102,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(mods));
|
||||
self.common.shell.set_overview_mode(Some(pattern.modifiers));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1110,6 +1117,10 @@ impl State {
|
|||
workspace.maximize_toggle(&window, ¤t_output);
|
||||
}
|
||||
}
|
||||
Action::Resizing(direction) => self
|
||||
.common
|
||||
.shell
|
||||
.set_resize_mode(Some((pattern, direction))),
|
||||
Action::ToggleOrientation => {
|
||||
let output = seat.active_output();
|
||||
let workspace = self.common.shell.active_space_mut(&output);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use smithay::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
config::{Config, KeyModifiers, OutputConfig, WorkspaceMode as ConfigMode},
|
||||
config::{Config, KeyModifiers, KeyPattern, OutputConfig, WorkspaceMode as ConfigMode},
|
||||
utils::prelude::*,
|
||||
wayland::protocols::{
|
||||
toplevel_info::ToplevelInfoState,
|
||||
|
|
@ -70,6 +70,19 @@ pub enum OverviewMode {
|
|||
Ended(Instant),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, serde::Deserialize, PartialEq, Eq, Hash)]
|
||||
pub enum ResizeDirection {
|
||||
Inwards,
|
||||
Outwards,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ResizeMode {
|
||||
None,
|
||||
Started(KeyPattern, Instant, ResizeDirection),
|
||||
Ended(Instant, ResizeDirection),
|
||||
}
|
||||
|
||||
pub struct Shell {
|
||||
pub popups: PopupManager,
|
||||
pub outputs: Vec<Output>,
|
||||
|
|
@ -88,6 +101,7 @@ pub struct Shell {
|
|||
|
||||
gaps: (u8, u8),
|
||||
overview_mode: OverviewMode,
|
||||
resize_mode: ResizeMode,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -546,6 +560,7 @@ impl Shell {
|
|||
|
||||
gaps: config.static_conf.gaps,
|
||||
overview_mode: OverviewMode::None,
|
||||
resize_mode: ResizeMode::None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1112,6 +1127,7 @@ impl Shell {
|
|||
sets.values().any(|set| set.previously_active.is_some())
|
||||
}
|
||||
}) || !matches!(self.overview_mode, OverviewMode::None)
|
||||
|| !matches!(self.resize_mode, ResizeMode::None)
|
||||
|| self
|
||||
.workspaces
|
||||
.spaces()
|
||||
|
|
@ -1146,6 +1162,31 @@ impl Shell {
|
|||
self.overview_mode.clone()
|
||||
}
|
||||
|
||||
pub fn set_resize_mode(&mut self, enabled: Option<(KeyPattern, ResizeDirection)>) {
|
||||
if let Some((pattern, direction)) = enabled {
|
||||
if let ResizeMode::Started(old_pattern, _, old_direction) = &mut self.resize_mode {
|
||||
*old_pattern = pattern;
|
||||
*old_direction = direction;
|
||||
} else {
|
||||
self.resize_mode = ResizeMode::Started(pattern, Instant::now(), direction);
|
||||
}
|
||||
} else {
|
||||
if let ResizeMode::Started(_, _, direction) = &self.resize_mode {
|
||||
self.resize_mode = ResizeMode::Ended(Instant::now(), *direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resize_mode(&mut self) -> ResizeMode {
|
||||
if let ResizeMode::Ended(timestamp, _) = self.resize_mode {
|
||||
if Instant::now().duration_since(timestamp) > ANIMATION_DURATION {
|
||||
self.resize_mode = ResizeMode::None;
|
||||
}
|
||||
}
|
||||
|
||||
self.resize_mode.clone()
|
||||
}
|
||||
|
||||
pub fn refresh(&mut self) {
|
||||
#[cfg(feature = "debug")]
|
||||
puffin::profile_function!();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue