From 75df858dbe0d497a66aaf2cd66fcb54d1fb8fe69 Mon Sep 17 00:00:00 2001 From: Salem Yaslem Date: Sun, 22 Oct 2023 00:00:39 +0300 Subject: [PATCH] enable recording of window or screen --- src/ffmpeg_interface.rs | 7 ++++++- src/main.rs | 18 ++++++++++++++---- src/wayland_record.rs | 15 +-------------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/ffmpeg_interface.rs b/src/ffmpeg_interface.rs index 6d9ccab..c7080e9 100644 --- a/src/ffmpeg_interface.rs +++ b/src/ffmpeg_interface.rs @@ -32,6 +32,7 @@ pub struct Ffmpeg { pub unbound: Option>, pub window: Window, pub record_wayland: WaylandRecorder, + pub record_window: Rc>, pub main_context: gtk::glib::MainContext, } @@ -145,7 +146,11 @@ impl Ffmpeg { "{}.temp.without.audio.webm", self.saved_filename.as_ref().unwrap() ), - RecordTypes::Monitor, + if self.record_window.take() { + RecordTypes::Window + } else { + RecordTypes::Monitor + }, { if self.record_mouse.is_active() { CursorModeTypes::Show diff --git a/src/main.rs b/src/main.rs index 0a08945..7e09a33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -436,16 +436,25 @@ 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(); + screen_grab_button.connect_clicked(move |_| { + __record_window.swap(&RefCell::new(false)); _area_chooser_window.hide(); _area_capture.borrow_mut().reset(); }); - let _area_chooser_window = area_chooser_window.clone(); - let mut _area_capture = area_capture.clone(); + let _area_chooser_window: Window = area_chooser_window.clone(); + let mut _area_capture: Rc> = area_capture.clone(); window_grab_button.connect_clicked(move |_| { _area_chooser_window.hide(); - _area_capture.borrow_mut().get_area(); + if is_wayland() { + record_window.swap(&RefCell::new(true)); + } else { + _area_capture.borrow_mut().get_area(); + } }); let _delay_spin = delay_spin.clone(); @@ -473,7 +482,8 @@ pub fn build_ui(application: &Application) { window: main_window.clone(), record_delay: delay_spin, record_wayland: wayland_record, - main_context: main_context, + record_window: _record_window, + main_context, })); // Record Button diff --git a/src/wayland_record.rs b/src/wayland_record.rs index b7c3ea5..da7867e 100644 --- a/src/wayland_record.rs +++ b/src/wayland_record.rs @@ -223,17 +223,4 @@ impl WaylandRecorder { println!("Recording Wayland screen cast..."); Ok(()) } -} - -// #[async_std::main] -// async fn main() -> Result<()> { -// let mut recorder = WaylandRecorder::new().await; -// recorder.start(RecordTypes::Monitor, CursorModeTypes::Show).await?; - -// // wait for user input to stop recording -// let mut input = String::new(); -// std::io::stdin().read_line(&mut input).unwrap(); - -// recorder.stop(); -// Ok(()) -// } +} \ No newline at end of file