forge
Explore
Log in

Don't you dare go Hollow

Animate xdg-activation and foreign-toplevel workspace switches

Browse files at this commit

793e1bdbc5fdbf99e264558375bd27cffabc4ec8Ivan MolodetskikhParent: d62721d
These are a bit jarring without an animation.
src/layout/mod.rsmodified+9 -5
@@ -43,8 +43,8 @@ use smithay::output::{self, Output};
43 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;43 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
44 use smithay::utils::{Logical, Point, Scale, Serial, Size, Transform};44 use smithay::utils::{Logical, Point, Scale, Serial, Size, Transform};
45 45
46-use self::monitor::Monitor;
47 pub use self::monitor::MonitorRenderElement;46 pub use self::monitor::MonitorRenderElement;
47+use self::monitor::{Monitor, WorkspaceSwitch};
48 use self::workspace::{compute_working_area, Column, ColumnWidth, OutputId, Workspace};48 use self::workspace::{compute_working_area, Column, ColumnWidth, OutputId, Workspace};
49 use crate::niri_render_elements;49 use crate::niri_render_elements;
50 use crate::render_helpers::renderer::NiriRenderer;50 use crate::render_helpers::renderer::NiriRenderer;
@@ -963,9 +963,13 @@ impl<W: LayoutElement> Layout<W> {
963 *active_monitor_idx = monitor_idx;963 *active_monitor_idx = monitor_idx;
964 ws.activate_window(window);964 ws.activate_window(window);
965 965
966- // Switch to that workspace if not already during a transition.966+ // If currently in the middle of a vertical swipe between the target workspace
967- if mon.workspace_switch.is_none() {967+ // and some other, don't switch the workspace.
968- mon.switch_workspace(workspace_idx);968+ match &mon.workspace_switch {
969+ Some(WorkspaceSwitch::Gesture(gesture))
970+ if gesture.current_idx.floor() == workspace_idx as f64
971+ || gesture.current_idx.ceil() == workspace_idx as f64 => {}
972+ _ => mon.switch_workspace(workspace_idx, true),
969 }973 }
970 974
971 break;975 break;
@@ -1388,7 +1392,7 @@ impl<W: LayoutElement> Layout<W> {
1388 let Some(monitor) = self.active_monitor() else {1392 let Some(monitor) = self.active_monitor() else {
1389 return;1393 return;
1390 };1394 };
1391- monitor.switch_workspace(idx);1395+ monitor.switch_workspace(idx, false);
1392 }1396 }
1393 1397
1394 pub fn switch_workspace_auto_back_and_forth(&mut self, idx: usize) {1398 pub fn switch_workspace_auto_back_and_forth(&mut self, idx: usize) {
src/layout/monitor.rsmodified+8 -7
@@ -569,12 +569,13 @@ impl<W: LayoutElement> Monitor<W> {
569 self.workspaces.iter().position(|w| w.id() == id)569 self.workspaces.iter().position(|w| w.id() == id)
570 }570 }
571 571
572- pub fn switch_workspace(&mut self, idx: usize) {572+ pub fn switch_workspace(&mut self, idx: usize, animate: bool) {
573 self.activate_workspace(min(idx, self.workspaces.len() - 1));573 self.activate_workspace(min(idx, self.workspaces.len() - 1));
574- // Don't animate this action.
575- self.workspace_switch = None;
576 574
577- self.clean_up_workspaces();575+ if !animate {
576+ self.workspace_switch = None;
577+ self.clean_up_workspaces();
578+ }
578 }579 }
579 580
580 pub fn switch_workspace_auto_back_and_forth(&mut self, idx: usize) {581 pub fn switch_workspace_auto_back_and_forth(&mut self, idx: usize) {
@@ -582,16 +583,16 @@ impl<W: LayoutElement> Monitor<W> {
582 583
583 if idx == self.active_workspace_idx {584 if idx == self.active_workspace_idx {
584 if let Some(prev_idx) = self.previous_workspace_idx() {585 if let Some(prev_idx) = self.previous_workspace_idx() {
585- self.switch_workspace(prev_idx);586+ self.switch_workspace(prev_idx, false);
586 }587 }
587 } else {588 } else {
588- self.switch_workspace(idx);589+ self.switch_workspace(idx, false);
589 }590 }
590 }591 }
591 592
592 pub fn switch_workspace_previous(&mut self) {593 pub fn switch_workspace_previous(&mut self) {
593 if let Some(idx) = self.previous_workspace_idx() {594 if let Some(idx) = self.previous_workspace_idx() {
594- self.switch_workspace(idx);595+ self.switch_workspace(idx, false);
595 }596 }
596 }597 }
597 598