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