|
|
@ -27,7 +27,10 @@ use serde::{Deserialize, Serialize}; |
|
|
|
use std::collections::HashMap; |
|
|
|
use std::collections::HashMap; |
|
|
|
use std::sync::atomic; |
|
|
|
use std::sync::atomic; |
|
|
|
use std::sync::Arc; |
|
|
|
use std::sync::Arc; |
|
|
|
|
|
|
|
use std::sync::Mutex; |
|
|
|
use std::sync::RwLock; |
|
|
|
use std::sync::RwLock; |
|
|
|
|
|
|
|
use std::time::Duration; |
|
|
|
|
|
|
|
use std::time::Instant; |
|
|
|
use swayipc as s; |
|
|
|
use swayipc as s; |
|
|
|
|
|
|
|
|
|
|
|
pub fn run_sway_command_1(cmd: &str) { |
|
|
|
pub fn run_sway_command_1(cmd: &str) { |
|
|
@ -225,6 +228,7 @@ impl SwayrCommand { |
|
|
|
pub struct ExecSwayrCmdArgs<'a> { |
|
|
|
pub struct ExecSwayrCmdArgs<'a> { |
|
|
|
pub cmd: &'a SwayrCommand, |
|
|
|
pub cmd: &'a SwayrCommand, |
|
|
|
pub extra_props: Arc<RwLock<HashMap<i64, t::ExtraProps>>>, |
|
|
|
pub extra_props: Arc<RwLock<HashMap<i64, t::ExtraProps>>>, |
|
|
|
|
|
|
|
pub sequence_timeout: Option<Duration>, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl DisplayFormat for SwayrCommand { |
|
|
|
impl DisplayFormat for SwayrCommand { |
|
|
@ -246,6 +250,9 @@ fn always_true(_x: &t::DisplayNode) -> bool { |
|
|
|
|
|
|
|
|
|
|
|
static IN_NEXT_PREV_WINDOW_SEQ: atomic::AtomicBool = |
|
|
|
static IN_NEXT_PREV_WINDOW_SEQ: atomic::AtomicBool = |
|
|
|
atomic::AtomicBool::new(false); |
|
|
|
atomic::AtomicBool::new(false); |
|
|
|
|
|
|
|
lazy_static! { |
|
|
|
|
|
|
|
static ref NEXT_PREV_WINDOW_SEQ_TIMEOUT: Mutex<Option<Instant>> = Mutex::new(None); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) { |
|
|
|
pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) { |
|
|
|
let props = args.extra_props; |
|
|
|
let props = args.extra_props; |
|
|
@ -253,14 +260,25 @@ pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) { |
|
|
|
if args.cmd.is_prev_next_window_variant() { |
|
|
|
if args.cmd.is_prev_next_window_variant() { |
|
|
|
let before = |
|
|
|
let before = |
|
|
|
IN_NEXT_PREV_WINDOW_SEQ.swap(true, atomic::Ordering::SeqCst); |
|
|
|
IN_NEXT_PREV_WINDOW_SEQ.swap(true, atomic::Ordering::SeqCst); |
|
|
|
if !before { |
|
|
|
if !before |
|
|
|
|
|
|
|
|| NEXT_PREV_WINDOW_SEQ_TIMEOUT |
|
|
|
|
|
|
|
.lock() |
|
|
|
|
|
|
|
.unwrap() |
|
|
|
|
|
|
|
.map_or(false, |i| Instant::now() > i) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
log::info!("Starting new next/prev sequence"); |
|
|
|
let mut map = props.write().unwrap(); |
|
|
|
let mut map = props.write().unwrap(); |
|
|
|
for val in map.values_mut() { |
|
|
|
for val in map.values_mut() { |
|
|
|
val.last_focus_tick_for_next_prev_seq = val.last_focus_tick; |
|
|
|
val.last_focus_tick_for_next_prev_seq = val.last_focus_tick; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if let Some(timeout) = args.sequence_timeout { |
|
|
|
|
|
|
|
*NEXT_PREV_WINDOW_SEQ_TIMEOUT.lock().unwrap() = |
|
|
|
|
|
|
|
Some(Instant::now() + timeout); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
IN_NEXT_PREV_WINDOW_SEQ.store(false, atomic::Ordering::SeqCst); |
|
|
|
IN_NEXT_PREV_WINDOW_SEQ.store(false, atomic::Ordering::SeqCst); |
|
|
|
|
|
|
|
*NEXT_PREV_WINDOW_SEQ_TIMEOUT.lock().unwrap() = None; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
match args.cmd { |
|
|
|
match args.cmd { |
|
|
@ -473,6 +491,7 @@ pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) { |
|
|
|
exec_swayr_cmd(ExecSwayrCmdArgs { |
|
|
|
exec_swayr_cmd(ExecSwayrCmdArgs { |
|
|
|
cmd: c, |
|
|
|
cmd: c, |
|
|
|
extra_props: props, |
|
|
|
extra_props: props, |
|
|
|
|
|
|
|
sequence_timeout: args.sequence_timeout, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|