From 5af98f95088189b03b80b024e73f8da98ab6d095 Mon Sep 17 00:00:00 2001 From: Salem Yaslem Date: Sun, 22 Oct 2023 04:47:31 +0300 Subject: [PATCH] remember last decision to record window or screen --- src/ffmpeg_interface.rs | 6 +++++- src/main.rs | 12 ++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ffmpeg_interface.rs b/src/ffmpeg_interface.rs index 2473fbc..b7007e4 100644 --- a/src/ffmpeg_interface.rs +++ b/src/ffmpeg_interface.rs @@ -141,12 +141,16 @@ impl Ffmpeg { self.video_process = Some(Rc::new(RefCell::new(ffmpeg_command.spawn().unwrap()))); } else if self.record_video.is_active() && is_wayland() { sleep(Duration::from_secs(self.record_delay.value() as u64)); + + let record_window = self.record_window.take(); + self.record_window.replace(record_window); + if !self.main_context.block_on(self.record_wayland.start( format!( "{}.temp.without.audio.webm", self.saved_filename.as_ref().unwrap() ), - if self.record_window.take() { + if record_window { RecordTypes::Window } else { RecordTypes::Monitor diff --git a/src/main.rs b/src/main.rs index 7e09a33..42313a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -437,11 +437,11 @@ pub fn build_ui(application: &Application) { let _area_chooser_window = area_chooser_window.clone(); let mut _area_capture = area_capture.clone(); let record_window: Rc> = Rc::new(RefCell::new(false)); - let _record_window: Rc> = record_window.clone(); - let __record_window: Rc> = record_window.clone(); + let window_grab_button_record_window: Rc> = record_window.clone(); + let screen_grab_button_record_window: Rc> = record_window.clone(); screen_grab_button.connect_clicked(move |_| { - __record_window.swap(&RefCell::new(false)); + screen_grab_button_record_window.replace(false); _area_chooser_window.hide(); _area_capture.borrow_mut().reset(); }); @@ -451,7 +451,7 @@ pub fn build_ui(application: &Application) { window_grab_button.connect_clicked(move |_| { _area_chooser_window.hide(); if is_wayland() { - record_window.swap(&RefCell::new(true)); + window_grab_button_record_window.replace(true); } else { _area_capture.borrow_mut().get_area(); } @@ -482,14 +482,14 @@ pub fn build_ui(application: &Application) { window: main_window.clone(), record_delay: delay_spin, record_wayland: wayland_record, - record_window: _record_window, + record_window, main_context, })); // Record Button let _delay_window = delay_window.clone(); let _delay_window_button = delay_window_button.clone(); - let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone(); + let _ffmpeg_record_interface = ffmpeg_record_interface.clone(); let _main_window = main_window.clone(); let _play_button = play_button.clone(); let _record_button = record_button.clone();