enable recording of window or screen

This commit is contained in:
Salem Yaslem 2023-10-22 00:00:39 +03:00
parent 5f079b86f4
commit 75df858dbe
3 changed files with 21 additions and 19 deletions

View File

@ -32,6 +32,7 @@ pub struct Ffmpeg {
pub unbound: Option<Sender<bool>>,
pub window: Window,
pub record_wayland: WaylandRecorder,
pub record_window: Rc<RefCell<bool>>,
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

View File

@ -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<RefCell<bool>> = Rc::new(RefCell::new(false));
let _record_window: Rc<RefCell<bool>> = record_window.clone();
let __record_window: Rc<RefCell<bool>> = 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<RefCell<area_capture::AreaCapture>> = 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

View File

@ -224,16 +224,3 @@ impl WaylandRecorder {
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(())
// }